Timers give us the ability to set up an artifact where the OS lets us know once the specified time has expired—is a ubiquitous application (and, indeed, kernel) feature. Of course, the timer is usually only useful if it is running in parallel with the application logic; this asynchronous notification behavior is achieved by different means, very often by having the kernel send the relevant process a signal.
In this chapter, we shall explore the available interfaces on Linux for setting up and working with timers. These interfaces fall into two broad categories—the older APIs (alarm(2), [get|set]itimer(2)), and the shiny, newer POSIX APIs (timer_create(2), timer_[set|get]time(2), and so on). Of course, as signals are quite heavily employed along with timers, we make use of the signal interfaces as well.
We would also like to point out that, due to the intrinsic...