我言简意赅的说:
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 9–14 of the expires field.
3 For timers expiring even farther, the same trick is used for bits 15–20, 21–26, and 27–31.
其实上面还应该添加上一句话,比如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。
果断插图: