What is a Kernel timer and how to use it in Linux 3.10 ?

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.

An example using the older jiffies-resolution timer API.



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión /  Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )


Conectando a %s