Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sleep(3) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

alarm

pause

signal

     sleep

Purpose

     Suspends execution of the current process for an interval
     of time.

Library

     Standard C Library (libc.a)

Syntax

     unsigned int sleep (seconds)
     unsigned int seconds;

Description

     The  sleep  subroutine  causes  the  current  process  to
     suspend execution for the  number of seconds specified by
     the seconds  parameter.  The sleep routine  sets an alarm
     and pauses until that alarm or some other signal occurs.

     The  actual  sleep time  of  the  process may  be  either
     shorter  or longer  than the  requested sleep  time.  The
     sleep time may be shorter because:

     o   Wakeups occur on the  second at fixed 1-second inter-
         vals according to an internal clock.

     o   Any caught signal terminates the sleep following exe-
         cution of that signal's catching routine.

     The sleep  time may  be longer  than the  requested sleep
     time due  to the  scheduling of  other activities  in the
     system.

     The  value  returned  by  the  sleep  subroutine  is  the
     requested sleep time minus the time actually slept.

     The process calling the sleep  subroutine may have set an
     alarm prior to calling the sleep subroutine.

     If a previous  alarm has been set, and  the sleep subrou-
     tine's sleep  time exceeds  the process's  previously set
     sleep time, the process only sleeps until the time speci-
     fied by  the previously set  alarm and the  calling proc-
     ess's  alarm catch  routine is  executed just  before the
     sleep subroutine returns.

     If a previous  alarm has been set, and  the sleep subrou-
     tine's sleep  time is less than  the process's previously
     set  sleep time,  the current  process is  suspended from
     execution  for the  number  of seconds  specified by  the

     sleep subroutine.   The previously set alarm  is reset to
     go off at  the same time it would have  without the sleep
     subroutines intervention.

     Warning:   The  results are  undefined  if,  while it  is
     sleeping, the  calling program issues any  other alarm or
     sleep calls.  This can happen  if a signal arrives in the
     interim and the signal handler calls alarm or sleep.

Related Information

     In this book:  "alarm," "pause," and "signal."

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