Re-enabled use of AROS.Boot file due to lack of general enthusiasm for
[tangerine.git] / arch / i386-pc / exec / settaskpri.c
bloba525a4d8d7ea4f31dd9025f5553baaebe4cec7d1
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Change the priority of a task.
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH2(BYTE, SetTaskPri,
19 /* SYNOPSIS */
20 AROS_LHA(struct Task *, task, A1),
21 AROS_LHA(LONG, priority, D0),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 50, Exec)
26 /* FUNCTION
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
29 -127 to 5.
31 INPUTS
32 task - Pointer to task structure.
33 priority - New priority of the task.
35 RESULT
36 Old task priority.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 HISTORY
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 BYTE old;
56 /* Always Disable() when doing something with task lists. */
57 Disable();
59 /* Get returncode */
60 old=task->tc_Node.ln_Pri;
62 /* Set new value. */
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;
87 else
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. */
98 Reschedule(task);
102 /* All done. */
103 Enable();
104 return old;
105 AROS_LIBFUNC_EXIT
106 } /* SetTaskPri */