jiffies:
the number of time ticks since kernel start
ex:
unsigned long timeout=jiffies+ 3*HZ;
// the time after 3 second
time_after(jiffies, timeout)
convert from jiffies to seconds
divide by HZ
time related methods:
time_after: parameter is time tick
time_before: parameter is time tick
schedule_timeout: parameter is time tick
only schedule_timeout will give up processor
wait_event_timeout:
msleep: parameter is milliseconds
timer example( do something in the future):
#include
struct timer_list my_timer;
init_timer(&my_timer); /* Also see setup_timer() */
my_timer.expire = jiffies + n*HZ; /* n is the timeout in number
of seconds */
my_timer.function = timer_func; /* Function to execute
after n seconds */
my_timer.data = func_parameter; /* Parameter to be passed
to timer_func */
add_timer(&my_timer); /* Start the timer */
沒有留言:
張貼留言