3 sleep, wakeup, tsleep, return0 \- process synchronisation
7 void sleep(Rendez *r, int (*f)(void*), void *arg)
10 void wakeup(Rendez *r)
13 void tsleep(Rendez *r, int (*f)(void*), void *arg, ulong ms)
16 int return0(void *arg)
19 A process running in the kernel can use these functions to
20 synchronise with an interrupt handler or another kernel process.
21 In particular, they are used by device drivers to wait for an event to be signalled on
22 receipt of an interrupt.
23 (In practice, they are most often used indirectly, through
33 structure, to provide a rendezvous point between them
34 to synchronise on an event.
36 uses a condition function
38 that returns true if the event has occurred.
43 If true, the event has happened and
48 blocks on the event variable
54 is called by either a process or an interrupt handler to wake any process
57 signifying that the corresponding condition is true (the event has occurred).
58 It has no effect if there is no sleeping process.
63 except that if the condition
65 is false and the caller does sleep,
66 and nothing else wakes it within
69 the system will wake it.
71 caller must check its environment to decide whether timeout or the event
73 The timing provided by
75 is imprecise, but adequate in practice for the normal use of protecting against
76 lost interrupts and otherwise unresponsive devices or software.
79 ignores its arguments and returns zero. It is commonly used as
84 to obtain a time delay, using the
90 structure, for example:
92 .B tsleep(&up->sleep, return0, nil, 10);
103 .B /sys/src/9/port/proc.c
105 .B /sys/src/9/port/sysproc.c
107 There can be at most one process waiting on a
109 and if two processes collide, the system will
111 .RB (`` "double sleep" '').
114 must therefore be serialised by some other mechanism, usually
121 ``Process Sleep and Wakeup on a Shared-memory Multiprocessor'',
123 .I "Plan 9 Programmer's Manual: Volume 2".