2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Send some signal to a given task
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
12 #include <aros/debug.h>
14 /*****************************************************************************
18 AROS_LH2(void, Signal
,
21 AROS_LHA(struct Task
*, task
, A1
),
22 AROS_LHA(ULONG
, signalSet
, D0
),
25 struct ExecBase
*, SysBase
, 54, Exec
)
28 Send some signals to a given task. If the task is currently waiting
29 on these signals, has a higher priority as the current one and if
30 taskswitches are allowed the new task begins to run immediately.
33 task - Pointer to task structure.
34 signalSet - The set of signals to send to the task.
39 This function may be used from interrupts.
46 AllocSignal(), FreeSignal(), Wait(), SetSignal(), SetExcept()
52 ******************************************************************************/
56 /* Protect the task lists against other tasks that may use Signal(). */
59 /* Set the signals in the task structure. */
60 task
->tc_SigRecvd
|=signalSet
;
62 /* Do those bits raise exceptions? */
63 if(task
->tc_SigExcept
&task
->tc_SigRecvd
)
65 /* Yes. Set the exception flag. */
66 task
->tc_Flags
|=TF_EXCEPT
;
68 /* task is running (Signal() called from within interrupt)? Raise the exception or defer it for later. */
69 if (task
->tc_State
==TS_RUN
)
71 /* Order a reschedule */
81 Is the task receiving the signals waiting on them
84 if((task
->tc_State
==TS_WAIT
)&&
85 (task
->tc_SigRecvd
&(task
->tc_SigWait
|task
->tc_SigExcept
)))
87 /* Yes. Move him to the ready list. */
88 task
->tc_State
=TS_READY
;
89 Remove(&task
->tc_Node
);
90 Enqueue(&SysBase
->TaskReady
,&task
->tc_Node
);
92 /* Has it a higher priority as the current one? */
93 if (task
->tc_Node
.ln_Pri
> SysBase
->ThisTask
->tc_Node
.ln_Pri
)
96 Yes. A taskswitch is necessary. Prepare one if possible.
97 (If the current task is not running it is already moved)
99 if (SysBase
->ThisTask
->tc_State
== TS_RUN
)