Implementation of Kernel Timers

我言简意赅的说:

1 if the timer expires in the next 0 to 255 jiffies, it is added to one of the 256 lists devoted to 
short
-range timers using the least significant bits of the expires field.

2 If it expires farther in the future (but before 16,384 jif-fies),
it is added to one of 64 lists based on bits 914 of the expires field.

3 For timers expiring even farther, the same trick is used for bits 1520, 2126, and 2731.

其实上面还应该添加上一句话,比如timer应该被加入到256 lists中,就应该用当前的jiffies的后9位加上timer->expires求余.
即(jiffies & 256 + timer-> expires) % 256.放到这个链表中。


然后运行的时候,该选择运行哪个链表呢?

1 When __run_timers is fired, it executes all pending timers for the current timer tick.

2 If jiffies is currently a multiple of 256, the function also rehashes one of the next-
level lists of timers into the 256 short-term lists, possibly cascading one or more of
the other levels as well, according to the bit representation of jiffies

简单说:应当将上一级链表在符号条件的时候重新hash到低一级的链表中。每个tick执行一个链表中的timer。

果断插图:



转载于:https://www.cnblogs.com/jack204/archive/2011/11/14/2248864.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值