[go: nahoru, domu]

Jump to content

Sleep (system call)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Loadmaster (talk | contribs) at 22:26, 5 March 2007 (Initial revision). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Proposed: Sleep (operating system)

A computer program (process or task) may sleep, which places it into an inactive state for a period of time. Eventually the expiration of an interval timer, or the receipt of a signal or interrupt causes the program to resume execution.

A typical sleep system call takes a time value as a parameter, specifying the maximum amount of time that the process is to sleep before resuming execution. The parameter typically specifies seconds, although some operating systems provide finer resolution, such as milliseconds or microseconds.

Some system programs that never terminate execute an infinite wait loop, going to sleep at the start of each cycle and waiting for some event to awaken them. Once an event is received, the program services the event, then returns to the beginning of the next wait cycle.

Other programs periodically poll for events by going to sleep and resuming execution after a specific interval of time. Once execution is resumed, the program polls for events or status changes, and then services any that occurred while it was asleep. After servicing the events, the program then goes to sleep again for the next time interval. Certain kinds of heartbeat events or keep-alive signals can be generated by these kinds of programs.

See also