- 论坛徽章:
- 0
|
这个问题是这样的,我们知道,linux中的计时是靠timer来提供的,timer每1/HZ个时间来一次中断,这个1/HZ个时间就叫做tick,而从系统开机走过了多少个tick,是通过jiffies来表明的,通过不断的来timer就可以消耗时间片,驱使系统进行schedule。那么timer如何保证是每1/HZ个时间就来一个interrupt呢?这就需要人为的告诉linux每个不同的platform上timer的clock是多少,然后就计算出timer中的reload value是多少,而local timer的reload value是如何计算的呢,其实有两种办法,一种是,人为标明local timer的clock是多少,然后和global timer一样,计算出reload value, 第二种办法是,让local timer先free run(reload value设为0xfffffff),然后delay 1/HZ,在读出reload value,两个相减就是local timer中 1/HZ的时间的reload value了
至于他们的作用
In a multiprocessor system, all general activities (such as handling of software timers) are triggered by the interrupts raised by the global timer, while CPU-specific activities (such as monitoring the execution time of the currently running process) are triggered by the interrupts raised by the local APIC timer
其实如果说他们到底是怎么区分的,也没有一个明确的答案,就是2个timer嘛,至于到底怎么用,就是user自己的问题了。。。 |
|