2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Wait for some signal.
10 #include <aros/debug.h>
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
13 #include <proto/exec.h>
14 #include <proto/kernel.h>
16 #include "exec_intern.h"
18 /*****************************************************************************
25 AROS_LHA(ULONG
, signalSet
, D0
),
28 struct ExecBase
*, SysBase
, 53, Exec
)
31 Wait until some signals are sent to the current task. If any signal
32 of the specified set is already set when entering this function it
33 returns immediately. Since almost any event in the OS can send a
34 signal to your task if you specify it to do so signals are a very
38 signalSet - The set of signals to wait for.
41 The set of active signals.
44 Naturally it's not allowed to wait in supervisor mode.
46 Calling Wait() breaks an active Disable() or Forbid().
53 Signal(), SetSignal(), AllocSignal(), FreeSignal()
59 ******************************************************************************/
66 /* Get pointer to current task - I'll need it very often */
69 D(bug("[Exec] Wait(0x%08lX) called by %s\n", signalSet
, me
->tc_Node
.ln_Name
));
70 /* Protect the task lists against access by other tasks. */
73 /* If at least one of the signals is already set do not wait. */
74 while(!(me
->tc_SigRecvd
&signalSet
))
76 D(bug("[Exec] Signals are not set, putting the task to sleep\n"));
77 /* Set the wait signal mask */
78 me
->tc_SigWait
=signalSet
;
81 Clear TDNestCnt (because Switch() will not care about it),
82 but memorize it first. IDNestCnt is handled by Switch().
84 me
->tc_TDNestCnt
=SysBase
->TDNestCnt
;
85 SysBase
->TDNestCnt
=-1;
87 /* Move current task to the waiting list. */
89 Enqueue(&SysBase
->TaskWait
,&me
->tc_Node
);
91 /* And switch to the next ready task. */
95 OK. Somebody awakened me. This means that either the
96 signals are there or it's just a finished task exception.
97 Test again to be sure (see above).
100 /* Restore TDNestCnt. */
101 SysBase
->TDNestCnt
=me
->tc_TDNestCnt
;
103 /* Get active signals. */
104 rcvd
=me
->tc_SigRecvd
&signalSet
;
106 /* And clear them. */
107 me
->tc_SigRecvd
&=~signalSet
;