Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sleep(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

alarm(S)

pause(S)

signal(S)


 sleep(S)                       6 January 1993                       sleep(S)


 Name

    sleep - suspend execution for interval

 Syntax


    cc  . . .  -lc


    unsigned sleep (seconds)
    unsigned seconds;


 Description

    The current process is suspended from execution for the number of seconds
    specified by the argument.  The actual suspension time may be less than
    that requested for two reasons: (1) Because scheduled wakeups occur at
    fixed 1-second intervals, (on the second, according to an internal clock)
    and (2) because any caught signal terminates the sleep following execu-
    tion of that signal's catching routine.  Also, the suspension time may be
    longer than requested by an arbitrary amount due to the scheduling of
    other activity in the system.  The value returned by sleep is the
    ``unslept'' amount (the requested time minus the time actually slept) in
    case the caller had an alarm set to go off earlier than the end of the
    requested sleep time, or premature arousal due to another caught signal.

    The routine is implemented by setting an alarm signal and pausing until
    it (or some other signal) occurs.  The previous state of the alarm signal
    is saved and restored.  The calling program may have set up an alarm sig-
    nal before calling sleep.  If the sleep time exceeds the time till such
    alarm signal, the process sleeps only until the alarm signal would have
    occurred.  The caller's alarm catch routine is executed just before the
    sleep routine returns.  But if the sleep time is less than the time till
    such alarm, the prior alarm time is reset to go off at the same time it
    would have without the intervening sleep.

 See also

    alarm(S), pause(S), signal(S)

 Standards conformance

    sleep is conformant with:
    AT&T SVID Issue 2;
    X/Open Portability Guide, Issue 3, 1989;
    IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C
    Language] (ISO/IEC 9945-1);
    and NIST FIPS 151-1.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026