Minor fixes to comments.
[AROS.git] / rom / exec / settaskpri.c
blobb2e635c366cc86e17bb2ac95d646e4da9c138e2a
1 /*
2 Copyright © 1995-2011, 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].
82 Reschedule();
85 /* All done. */
86 Enable();
87 return old;
89 AROS_LIBFUNC_EXIT
90 } /* SetTaskPri */