Linxu 时间管理

                                     一, jiffies

1,get_jiffies_64 获取jiffies. HZ, 时间比较函数,time_after(a, b)等,时间转换jiffies_to_msecs();等。

 2, 长延时,忙等待方式。     unsigned long j = jiffies + HZ; while(time_before(jiffies, j))  cpu_relax();

                   让出处理器方式。 unsigned long j = jiffies + HZ; while(time_before(jiffies, j))  schedule();

                   让出处理器方式(内核提供的基础设施),set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(jiffies + HZ);  mssleep();

3,短延时:内核提供了      mdelay, udelay, ndelay函数。

 

                                   二, 内核定时器,

1.struct timer_list my_timer;void init_timer(struct timer_list * timer);setup_timer()也可用于初始化定时器并赋值其成员

static inline void setup_timer(struct timer_list * timer, void (*function)(unsignedlong), unsigned long data)

void add_timer(struct timer_list * timer);int del_timer(struct timer_list * timer);int mod_timer(struct timer_list *timer, unsigned long expires);

 

posted on 2019-12-05 14:14  yangjunhe  阅读(136)  评论(0)    收藏  举报