# Linux Kernel Module Cheat

### 17.10. Timers

Count from `0` to `9` infinitely many times in 1 second intervals using timers:

    insmod timer.ko

Stop counting:

    rmmod timer

Source: kernel_modules/timer.c

Timers are callbacks that run when an interrupt happens, from the interrupt context itself.

Therefore they produce more accurate timing than thread scheduling, which is more complex, but you can’t do too much work inside of them.

Bibliography:

- https://stackoverflow.com/questions/10812858/timers-in-linux-device-drivers

- https://gist.github.com/yagihiro/310149