Linux timer mechanism, supplement

xiaoxiao2021-03-06  61

Any CPU If you want to support the operating system, you must have a programmable internal timer, periodically to issue a timer interrupt, this periodic timer interrupt called System Clock Tick, Linux Time Management is used JIFFIES unit, this is a global variable in the kernel, each time the timer interrupt arrivals, from 1. Linux has two types of system timers, the first, and the older scheme, is a static pointer array of 32 pointers that point to the Timer Struct structure, and a mask of a timer currently active. (Timer_Active), the Timer Structure points to this pointer array is internal definition that is set when the system is initialized. This is very like bottom HALF HANDLER TABLE BH_BASE, is not available for users, only serving the kernel. The second, is also a newer solution, that is, the linked list is a linked list of the Timer_List structure, which is sorted in the order of Expire Time. When each Clock Tick is interrupted, the system (because it is a clock interrupt processing function) puts the Timer Bottom Handler flag position bit, when the scheduler (Schaduler) is running Next time (See Bottom Half for Detail, Timer Bottom Half Handler will process the above. For the former, its mask (Timer_Active) is processed in the order of Bit 1 to Bit 32 (divided into Bottom Hadler Table Bh_Base), if Bit X is set and expired, BH_BASE is called. The processing function in X-1] will be RESET BIT X. For the latter, the system will traverse this linked list. When entry expired, the system will call the corresponding processing function, then this Expired Entry will be removed from the list. The benefit of the latter is that you can pass your own corresponding parameters for the timeout handler.

转载请注明原文地址:https://www.9cbs.com/read-111951.html

New Post(0)