O'Reilly logo

The Linux Programming Interface by Michael Kerrisk

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23. Timers and Sleeping

A timer allows a process to schedule a notification for itself to occur at some time in the future. Sleeping allows a process (or thread) to suspend execution for a period of time. This chapter describes the interfaces used for setting timers and for sleeping. It covers the following topics:

  • the classical UNIX APIs for setting interval timers (setitimer() and alarm()) to notify a process when a certain amount of time has passed;

  • the APIs that allow a process to sleep for a specified interval;

  • the POSIX.1b clocks and timers APIs; and

  • the Linux-specific timerfd facility, which allows the creation of timers whose expirations can be read from a file descriptor.

Interval Timers

The setitimer() system call establishes an

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required