Kernel timers are used to delay a function’s execution until an specified time interval has elapsed. The function will be run on the cpu on which it is submitted
These are the facts to know when we’ve got to use kernel timers
* Every time a timer interrupt occurs, the value of an internal kernel counter is incremented.
* The counter is initialized to 0 at system boot, so it represents the number of clock ticks since last boot.
* Driver writers normally wanna know the value of that counter. It is posible accessing the jiffies variable.
* Kernel timers are based on the clock tick.
* The functions scheduled to run almost certainly do not run while the process that registered them is executing. In fact kernel timers are run as the result of a “software interrupt”.
When we are outside of process context (and we are into the software interrupt context), we must observe the following rules:
* No access to user space is allowed.
* The current pointer is not meaningful and cannot be used
* No sleeping or scheduling may be performed. (not use “schedule” “wait_event” , semaphores , or any other function that could sleep. For example, calling kmalloc(…, GFP_KERNEL) is against the rules.