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>
11 #include <proto/kernel.h>
13 #include "../kernel/kernel_intern.h"
15 /*****************************************************************************
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 ******************************************************************************/
62 void *KernelBase
= getKernelBase();
64 /* Get pointer to current task - I'll need it very often */
67 /* Protect the task lists against access by other tasks. */
70 /* If at least one of the signals is already set do not wait. */
71 while(!(me
->tc_SigRecvd
&signalSet
))
75 /* Set the wait signal mask */
76 me
->tc_SigWait
=signalSet
;
79 Clear TDNestCnt (because Switch() will not care about it),
80 but memorize it first. IDNestCnt is handled by Switch().
81 This could as well be stored in a local variable which makes
82 the tc_TDNestCnt field somehow redundant.
84 old_TDNestCnt
=SysBase
->TDNestCnt
;
85 SysBase
->TDNestCnt
=-1;
87 /* Move current task to the waiting list. */
94 // me->tc_Node.ln_Pred->ln_Succ = me->tc_Node.ln_Succ;
95 // me->tc_Node.ln_Succ->ln_Pred = me->tc_Node.ln_Pred;
97 Enqueue(&SysBase
->TaskWait
,&me
->tc_Node
);
99 /* And switch to the next ready task. */
105 OK. Somebody awakened me. This means that either the
106 signals are there or it's just a finished task exception.
107 Test again to be sure (see above).
110 /* Restore TDNestCnt. */
111 SysBase
->TDNestCnt
=old_TDNestCnt
;
113 /* Get active signals. */
114 rcvd
=me
->tc_SigRecvd
&signalSet
;
116 /* And clear them. */
117 me
->tc_SigRecvd
&=~signalSet
;