2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Send some signal to a given task
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
11 #include <aros/debug.h>
13 /*****************************************************************************
17 AROS_LH2(void, Signal
,
20 AROS_LHA(struct Task
*, task
, A1
),
21 AROS_LHA(ULONG
, signalSet
, D0
),
24 struct ExecBase
*, SysBase
, 54, Exec
)
27 Send some signals to a given task. If the task is currently waiting
28 on these signals, has a higher priority as the current one and if
29 taskswitches are allowed the new task begins to run immediately.
32 task - Pointer to task structure.
33 signalSet - The set of signals to send to the task.
38 This function may be used from interrupts.
45 AllocSignal(), FreeSignal(), Wait(), SetSignal(), SetExcept()
49 ******************************************************************************/
53 /* Protect the task lists against other tasks that may use Signal(). */
56 /* Set the signals in the task structure. */
57 task
->tc_SigRecvd
|=signalSet
;
59 /* Do those bits raise exceptions? */
60 if(task
->tc_SigExcept
&task
->tc_SigRecvd
)
62 /* Yes. Set the exception flag. */
63 task
->tc_Flags
|=TF_EXCEPT
;
65 /* task is running? Raise the exception or defer it for later. */
66 if(task
->tc_State
==TS_RUN
)
68 /* Are taskswitches allowed? (Don't count own Disable() here) */
69 if(SysBase
->TDNestCnt
>=0||SysBase
->IDNestCnt
>0)
70 /* No. Store it for later. */
71 SysBase
->AttnResched
|=0x80;
74 /* Switches are allowed. Move the current task away. */
75 SysBase
->ThisTask
->tc_State
=TS_READY
;
76 Enqueue(&SysBase
->TaskReady
,&SysBase
->ThisTask
->tc_Node
);
78 /* And force a rescedule. */
89 Is the task receiving the signals waiting on them
92 if(task
->tc_State
==TS_WAIT
&&
93 (task
->tc_SigRecvd
&(task
->tc_SigWait
|task
->tc_SigExcept
)))
95 /* Yes. Move him to the ready list. */
96 task
->tc_State
=TS_READY
;
97 Remove(&task
->tc_Node
);
98 Enqueue(&SysBase
->TaskReady
,&task
->tc_Node
);
100 /* Has it a higher priority as the current one? */
101 if(task
->tc_Node
.ln_Pri
>SysBase
->ThisTask
->tc_Node
.ln_Pri
)
104 Yes. A taskswitch is necessary. Prepare one if possible.
105 (If the current task is not running it is already moved)
107 if(SysBase
->ThisTask
->tc_State
==TS_RUN
)
109 /* Are taskswitches allowed? */
110 if(SysBase
->TDNestCnt
>=0||SysBase
->IDNestCnt
>0)
112 /* No. Store it for later. */
113 SysBase
->AttnResched
|=0x80;
117 /* Switches are allowed. Move the current task away. */
118 SysBase
->ThisTask
->tc_State
=TS_READY
;
119 Enqueue(&SysBase
->TaskReady
,&SysBase
->ThisTask
->tc_Node
);
121 /* And force a rescedule. */