Timers

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 ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.