Blob


1 .TH SLEEP 3
2 .SH NAME
3 sleep, alarm \- delay, ask for delayed note
4 .SH SYNOPSIS
5 .B #include <u.h>
6 .br
7 .B #include <libc.h>
8 .PP
9 .B
10 int sleep(long millisecs)
11 .PP
12 .B
13 long alarm(unsigned long millisecs)
14 .SH DESCRIPTION
15 .I Sleep
16 suspends the current process for the number
17 of milliseconds specified by the argument.
18 The actual suspension time may be a little more or less than
19 the requested time. If
20 .I millisecs
21 is 0, the process
22 gives up the CPU if another process is waiting to run, returning
23 immediately if not.
24 Sleep returns \-1 if interrupted, 0 otherwise.
25 .PP
26 .I Alarm
27 causes an
28 .B alarm
29 note (see
30 .MR notify (3) )
31 to be sent to the invoking process after the number of milliseconds
32 given by the argument.
33 Successive calls to
34 .I alarm
35 reset the alarm clock.
36 A zero argument clears the alarm.
37 The return value is the amount of time previously remaining in
38 the alarm clock.
39 .SH SOURCE
40 .B \*9/src/lib9/sleep.c
41 .SH SEE ALSO
42 .MR intro (3)
43 .SH DIAGNOSTICS
44 These functions set
45 .IR errstr .
46 .SH BUGS
47 To avoid name conflicts with the underlying system,
48 .I sleep
49 and
50 .I alarm
51 are preprocessor macros defined as
52 .I p9sleep
53 and
54 .IR p9alarm ;
55 see
56 .MR intro (3) .