2 Copyright © 1995-2001, 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? Raise the exception or defer it for later. */
69 if(task
->tc_State
==TS_RUN
)
71 /* Are taskswitches allowed? (Don't count own Disable() here) */
72 if(SysBase
->TDNestCnt
>=0||SysBase
->IDNestCnt
>0)
73 /* No. Store it for later. */
74 SysBase
->AttnResched
|=0x80;
77 /* Switches are allowed. Move the current task away. */
78 // SysBase->ThisTask->tc_State=TS_READY;
79 // Enqueue(&SysBase->TaskReady,&SysBase->ThisTask->tc_Node);
81 /* And force a rescedule. */
92 Is the task receiving the signals waiting on them
96 if((task
->tc_State
==TS_WAIT
)&&
97 (task
->tc_SigRecvd
&(task
->tc_SigWait
|task
->tc_SigExcept
)))
99 /* Yes. Move him to the ready list. */
100 task
->tc_State
=TS_READY
;
101 Remove(&task
->tc_Node
);
102 Enqueue(&SysBase
->TaskReady
,&task
->tc_Node
);
104 /* Has it a higher priority as the current one? */
105 if(task
->tc_Node
.ln_Pri
>SysBase
->ThisTask
->tc_Node
.ln_Pri
)
108 Yes. A taskswitch is necessary. Prepare one if possible.
109 (If the current task is not running it is already moved)
111 if(SysBase
->ThisTask
->tc_State
==TS_RUN
)
113 /* Are taskswitches allowed? */
114 if(SysBase
->TDNestCnt
>=0||SysBase
->IDNestCnt
>0)
116 /* No. Store it for later. */
117 SysBase
->AttnResched
|=0x80;
121 /* Switches are allowed. Move the current task away. */
122 //SysBase->ThisTask->tc_State=TS_READY;
123 //Enqueue(&SysBase->TaskReady,&SysBase->ThisTask->tc_Node);
125 /* And force a rescedule. */