Linux 时钟管理
/* * Decide where to put the timer while taking the slack into account * * Algorithm: * 1) calculate the maximum (absolute) time * 2) calculate the highest bit where the expires and new max are different * 3) use this bit to make a mask * 4) use the bitmask to round down the maximum time, so that all last * bits are zeros */ static inline unsigned long apply_slack(struct timer_list *timer, unsigned long expires) { unsigned long expires_limit, mask; int bit; expires_limit = expires; if (timer->slack >= 0) { expires_limit = expires + timer->slack; } else { unsigned long now = jiffies; /* avoid reading jiffies twice */ /* if already expired, no slack; otherwise slack 0.4% */ if (time_after(expires, now)) expires_limit = expires + (expires - now)/256; } mask = expires ^ expires_limit; if (mask == 0) return expires; bit = find_last_bit(&mask, BITS_PER_LONG); mask = (1 << bit) - 1; expires_limit = expires_limit & ~(mask); return expires_limit; } 随着现代计算机系统的发展,对节能的需求越来越高,尤其是在使用笔记本,手持设备等移动环境是对节能要求更高。Linux 当然也会更加关注这方面的需求。hrtimer 子系统的优化尽量确保在使用高精度的时钟的同时节约能源,如果系统在空闲时也可以尽量的节能,则 Linux 系统的节能优势可以进一步放大。这也是引入 dynamic tick 的根本原因。 Dynamic tick & tickless 在 dynamic tick 引入之前,内核一直使用周期性的基于 HZ 的 tick。传统的 tick 机制在系统进入空 |
- stm8s开发(五) TIMER的使用:定时!(09-18)
- STM8S Timer2_OC1_PWM1输出模式(12-03)
- TimerA流水灯问题分析(12-02)
- LPC2103之timer0 ang timer1(11-29)
- MSP430F5529 (六)定时器Timer_A-1(11-28)
- MSP430F5529 (六)定时器Timer_A-2(11-28)