Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How are kernel timers described in linux kernel?


Asked by Abel Roman on Dec 07, 2021 Linux



Kernel timers are described by the hrtimer structure, defined in <linux/hrtimer.h>: expires – the absolute expiry time in the hr timers internal representation. The time is related to the clock on which the timer is based.
Additionally,
A timer is characterized by its timeout value (in jiffies) and the function to be called when the timer expires. The timer handler receives an argument, which is stored in the data structure, together with a pointer to the handler itself. The data structure of a timer looks like the following, which is extracted from <linux/timer.h> ):
Subsequently, In Linux, the kernel keeps track of the flow of time by means of timer interrupts. These timer interrupts are generated at regular timer intervals by using the system’s timing hardware. Every time a timer interrupt occurs, the value of an internal kernel counter is incremented.
Keeping this in consideration,
Linux Kernel provides the driver to create timers that are not periodic by default, register the timers and delete the timers. We need to include the <linux/timer.h> ( #include <linux/timer.h>) in order to use kernel timers. Kernel timers are described by the timer_list structure, defined in <linux/timer.h>: /* ... */
One may also ask,
Tickless kernel, dynamic ticks or NO_HZ is a config option that enables a kernel to run without a regular timer tick. The timer tick is a timer interrupt that is usually generated HZ times per second, with the value of HZ being set at compile time and varying between around 100 to 1500.