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 /*****************************************************************************
16 extern void Exec_Switch();
22 AROS_LHA(ULONG
, signalSet
, D0
),
25 struct ExecBase
*, SysBase
, 53, Exec
)
28 Wait until some signals are sent to the current task. If any signal
29 of the specified set is already set when entering this function it
30 returns immediately. Since almost any event in the OS can send a
31 signal to your task if you specify it to do so signals are a very
35 signalSet - The set of signals to wait for.
38 The set of active signals.
41 Naturally it's not allowed to wait in supervisor mode.
43 Calling Wait() breaks an active Disable() or Forbid().
50 Signal(), SetSignal(), AllocSignal(), FreeSignal()
56 ******************************************************************************/
63 /* Get pointer to current task - I'll need it very often */
66 /* Protect the task lists against access by other tasks. */
69 /* If at least one of the signals is already set do not wait. */
70 while(!(me
->tc_SigRecvd
&signalSet
))
74 /* Set the wait signal mask */
75 me
->tc_SigWait
=signalSet
;
78 Clear TDNestCnt (because Switch() will not care about it),
79 but memorize it first. IDNestCnt is handled by Switch().
80 This could as well be stored in a local variable which makes
81 the tc_TDNestCnt field somehow redundant.
83 old_TDNestCnt
=SysBase
->TDNestCnt
;
84 SysBase
->TDNestCnt
=-1;
86 /* Move current task to the waiting list. */
93 // me->tc_Node.ln_Pred->ln_Succ = me->tc_Node.ln_Succ;
94 // me->tc_Node.ln_Succ->ln_Pred = me->tc_Node.ln_Pred;
96 Enqueue(&SysBase
->TaskWait
,&me
->tc_Node
);
98 /* And switch to the next ready task. */
99 Supervisor(__AROS_GETVECADDR(SysBase
,9));
104 OK. Somebody awakened me. This means that either the
105 signals are there or it's just a finished task exception.
106 Test again to be sure (see above).
109 /* Restore TDNestCnt. */
110 SysBase
->TDNestCnt
=old_TDNestCnt
;
112 /* Get active signals. */
113 rcvd
=me
->tc_SigRecvd
&signalSet
;
115 /* And clear them. */
116 me
->tc_SigRecvd
&=~signalSet
;