Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / exec / settaskpri.c
blob95d4ffab458a58f825959f1dc1b836a54200bb2e
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 */
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH2(BYTE, SetTaskPri,
18 /* SYNOPSIS */
19 AROS_LHA(struct Task *, task, A1),
20 AROS_LHA(LONG, priority, D0),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 50, Exec)
25 /* FUNCTION
26 Change the priority of a given task. As a general rule the higher
27 the priority the more CPU time a task gets. Useful values are within
28 -127 to 5.
30 INPUTS
31 task - Pointer to task structure.
32 priority - New priority of the task.
34 RESULT
35 Old task priority.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 ******************************************************************************/
49 AROS_LIBFUNC_INIT
51 BYTE old;
53 /* Always Disable() when doing something with task lists. */
54 Disable();
56 /* Get returncode */
57 old=task->tc_Node.ln_Pri;
59 /* Set new value. */
60 task->tc_Node.ln_Pri=priority;
62 /* Check if the task is willing to run. */
63 if(task->tc_State!=TS_WAIT)
65 /* If it is in the ready list remove and reinsert it. */
66 if(task->tc_State==TS_READY)
68 Remove(&task->tc_Node);
69 Enqueue(&SysBase->TaskReady,&task->tc_Node);
73 I could check the task priorities here to determine if
74 the following is really necessary, but OTOH priority
75 changes are rare and the hassle isn't really worth it.
77 This should be reconsidered, because of Executive [ldp].
80 /* Are taskswitches allowed? */
81 if(SysBase->TDNestCnt>=0||SysBase->IDNestCnt>0)
82 /* No. Store it for later. */
83 SysBase->AttnResched|=0x80;
84 else
86 /* Switches are allowed. Move the current task away. */
87 SysBase->ThisTask->tc_State=TS_READY;
88 Enqueue(&SysBase->TaskReady,&SysBase->ThisTask->tc_Node);
90 /* And force a reschedule. */
91 Switch();
95 /* All done. */
96 Enable();
97 return old;
98 AROS_LIBFUNC_EXIT
99 } /* SetTaskPri */