timer_pending

一个处于pending状态的定时器是处在处理器的定时器管理队列中正等待被调度执行的定时器对象
timer_pending是用来判断一个处在定时器管理队列中的定时器  对象  是否  已经被  调度执行
add_timer只是把一个定时器对象加入到内核的管理队列,但是何时执行实际上由时钟中断(更确切地,是内核在时钟中断的softirq部分才开始扫描定时器管理队列),一个定时器对象pending意味着它的回调函数 尚未 被调度执行,而一旦一个定时器对象  被调度执行  ,之后它将被从定时器管理队列中摘除,除非  它再次  被提交。

void add_timer(struct timer_list *timer)
{
BUG_ON(timer_pending(timer));        
mod_timer(timer, timer->expires);//修改定时的时间.
}

 * return value: 1 if the timer is pending, 0 if not.
//没有被调度执行,返回0. 正在被吊住执行返回1.
static inline int timer_pending(const struct timer_list * timer)
{
return timer->entry.next != NULL;
}


//mod_time()激活定时器,激活没有激活的定事情,返回0.激活已经激活的返回0.
 * mod_timer() is a more efficient way to update the expire field of an
 * active timer (if the timer is inactive it will be activated)

 * The function returns whether it has modified a pending timer or not.
 * (ie. mod_timer() of an inactive timer returns 0, mod_timer() of an
 * active timer returns 1.)

struct timer_list {
struct list_head entry;
unsigned long expires;
struct tvec_base *base;
void (*function)(unsigned long);
unsigned long data;
}

init_timer(&timer); 这个时候就是初始化entry == NULL

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值