2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Change the priority of a task.
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
17 AROS_LH2(BYTE
, SetTaskPri
,
20 AROS_LHA(struct Task
*, task
, A1
),
21 AROS_LHA(LONG
, priority
, D0
),
24 struct ExecBase
*, SysBase
, 50, Exec
)
27 Change the priority of a given task. As a general rule the higher
28 the priority the more CPU time a task gets. Useful values are within
32 task - Pointer to task structure.
33 priority - New priority of the task.
50 ******************************************************************************/
56 /* Always Disable() when doing something with task lists. */
60 old
=task
->tc_Node
.ln_Pri
;
63 task
->tc_Node
.ln_Pri
=priority
;
65 /* Check if the task is willing to run. */
66 if(task
->tc_State
!=TS_WAIT
)
68 /* If it is in the ready list remove and reinsert it. */
69 if(task
->tc_State
==TS_READY
)
71 Remove(&task
->tc_Node
);
72 Enqueue(&SysBase
->TaskReady
,&task
->tc_Node
);
76 I could check the task priorities here to determine if
77 the following is really necessary, but OTOH priority
78 changes are rare and the hassle isn't really worth it.
80 This should be reconsidered, because of Executive [ldp].
83 /* Are taskswitches allowed? */
84 if(SysBase
->TDNestCnt
>=0||SysBase
->IDNestCnt
>0)
85 /* No. Store it for later. */
86 SysBase
->AttnResched
|=0x80;
89 /* Switches are allowed. Move the current task away. */
90 // SysBase->ThisTask->tc_State=TS_READY;
92 // task->tc_Node.ln_Pred->ln_Succ = task->tc_Node.ln_Succ;
93 // task->tc_Node.ln_Succ->ln_Pred = task->tc_Node.ln_Pred;
95 // Enqueue(&SysBase->TaskReady,&SysBase->ThisTask->tc_Node);
97 /* And force a reschedule. */