struct list_head
{
struct list_head *next;
struct list_head *prev;
};
expires = jiffies + 5*HZ; 定时5秒,时间到后执行function函数,data是传递给该函数的参数。
struct timer_list
{
struct list_head entry;
unsigned long expires;
void (*function)(unsigned long);
unsigned long data;
struct tvec_base *base;
};
void init_timer(struct timer_list *timer);初始化定时器
void add_timer(struct timer_list *timer); 启动定时器
int del_timer(struct timer_list *timer);
在定时器超时前将它删除,当定时器超时后,系统自动将它删除。
如果对时间要求不是很精确的情况下可以这么做:
int delay_t = 5;
unsigned long jiffies_t = jiffies + delay_t * HZ;
while(jiffies >=jiffies_t)
{
do something!
}
阅读(1867) | 评论(0) | 转发(0) |