2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Wait for some signal.
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
19 AROS_LHA(ULONG
, signalSet
, D0
),
22 struct ExecBase
*, SysBase
, 53, Exec
)
25 Wait until some signals are sent to the current task. If any signal
26 of the specified set is already set when entering this function it
27 returns immediately. Since almost any event in the OS can send a
28 signal to your task if you specify it to do so signals are a very
32 signalSet - The set of signals to wait for.
35 The set of active signals.
38 Naturally it's not allowed to wait in supervisor mode.
40 Calling Wait() breaks an active Disable() or Forbid().
47 Signal(), SetSignal(), AllocSignal(), FreeSignal()
51 ******************************************************************************/
58 /* Get pointer to current task - I'll need it very often */
61 /* Protect the task lists against access by other tasks. */
64 /* If at least one of the signals is already set do not wait. */
65 while(!(me
->tc_SigRecvd
&signalSet
))
69 /* Set the wait signal mask */
70 me
->tc_SigWait
=signalSet
;
73 Clear TDNestCnt (because Switch() will not care about it),
74 but memorize it first. IDNestCnt is handled by Switch().
75 This could as well be stored in a local variable which makes
76 the tc_TDNestCnt field somehow redundant.
78 old_TDNestCnt
=SysBase
->TDNestCnt
;
79 SysBase
->TDNestCnt
=-1;
81 /* Move current task to the waiting list. */
83 Enqueue(&SysBase
->TaskWait
,&me
->tc_Node
);
85 /* And switch to the next ready task. */
88 OK. Somebody awakened me. This means that either the
89 signals are there or it's just a finished task exception.
90 Test again to be sure (see above).
93 /* Restore TDNestCnt. */
94 SysBase
->TDNestCnt
=old_TDNestCnt
;
96 /* Get active signals. */
97 rcvd
=me
->tc_SigRecvd
&signalSet
;
100 me
->tc_SigRecvd
&=~signalSet
;