The Linux Programming Interface

(nextflipdebug5) #1

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:

z the classical UNIX APIs for setting interval timers (setitimer() and alarm()) to
notify a process when a certain amount of time has passed;
z the APIs that allow a process to sleep for a specified interval;
z the POSIX.1b clocks and timers APIs; and
z the Linux-specific timerfd facility, which allows the creation of timers whose
expirations can be read from a file descriptor.

23.1 Interval Timers...........................................................................................................


The setitimer() system call establishes an interval timer, which is a timer that expires
at a future point in time and (optionally) at regular intervals after that.
Free download pdf