High Resolution Timers
After having discussed the generic time framework, we are now ready to take the next step and dive into the implementation of high-resolution timers. Two fundamental differences distinguish these timers from low-resolution timers:
1. High-resolution (high-res) timers are time-ordered on a red-black tree.
2. They are independent of periodic ticks. They do not use a time specification based on jiffies, but employ nanosecond time stamps.
Merging the high-resolution timer mechanism into the kernel was an interesting process in itself. After the usual development and testing phase, kernel 2.6.16 contained the basic framework that provided most of the implementation except one thing: support for high-resolution timers ... . The classical implementation of low-resolution timers had, however, been replaced with a new foundation in this release. It was based on the high-resolution timer framework, although the supported resolution was not any better than before. Following kernel releases then added support for another class of timers that did actually provide high-resolution capabilities.
This merge strategy is not only of historical interest: Since low-resolution timers are implemented on top of the high-resolution mechanism, (partial) support for high-resolution timers will also be built into the kernel even if support for them is not explicitly enabled! Nevertheless, the system will only be able to provide timers with low-resolution capabilities.
14Note that 0 is returned on success, so !clockevents_program_event(...) checks for failure.
Components of the high-resolution timer framework that are not universally applicable, but do really provide actual high-resolution capabilites are bracketed by the pre-processor symbol config_high_res_timers, and are only compiled in if high-resolution support is selected at compile time. The generic part of the framework is always added to the kernel.
Continue reading here: Data Structures
Was this article helpful?