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

果断插图:



posted @ 2011-11-14 20:19  Jack204  阅读(153)  评论(0编辑  收藏  举报