Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / exec / reschedule.c
blobe1108cf79981e32705436fd215eda20ff5205585
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Reschedule() - Put a task back into the ready or waiting list.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/types.h>
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
14 /*****i***********************************************************************
16 NAME */
17 #include <proto/exec.h>
19 AROS_LH1(void, Reschedule,
21 /* SYNOPSIS */
22 AROS_LHA(struct Task *, task, A0),
24 /* LOCATION */
25 struct ExecBase *, SysBase, 8, Exec)
27 /* FUNCTION
28 Reschedule will place the task into one of Execs internal task
29 lists. Which list it is placed in will depend upon whether the
30 task is ready to run, or whether it is waiting for an external
31 event to awaken it.
33 It is possible that in the future, more efficient schedulers
34 will be implemented. In which case this is the function that they
35 need to implement.
37 You should not do any costly calculations since you will be
38 running in interupt mode.
40 INPUTS
41 task - The task to insert into the list.
43 RESULT
44 The task will be inserted into one of Exec's task lists.
46 NOTES
47 Not actually complete yet. Some of the task states don't have any
48 supplied action.
50 EXAMPLE
52 BUGS
53 Only in relation to the comments within about low-priority tasks
54 not getting any processor time.
56 SEE ALSO
58 INTERNALS
60 ******************************************************************************/
62 AROS_LIBFUNC_INIT
65 The code in here defines how "good" the task switching is.
66 There are seveal things which should be taken into account:
68 1. No task should block the CPU forever even if it is an
69 endless loop.
71 2. Tasks with a higher priority should get the CPU more often.
73 3. Tasks with a low priority should get the CPU every now and then.
75 Enqueue() fulfills 2 but not 1 and 3. AddTail() fulfills 1 and 3.
77 A better way would be to "deteriorate" a task, ie. decrease the
78 priority and use Enqueue() but at this time, I can't do this
79 because I have no good way to extend the task structure (I
80 need a variable to store the original prio).
83 /* Somebody had better have set the tasks state properly */
85 switch(task->tc_State)
87 case TS_READY:
88 Enqueue(&SysBase->TaskReady, (struct Node *)task);
89 break;
91 case TS_ADDED:
92 Enqueue(&SysBase->TaskReady, (struct Node *)task);
93 break;
96 We don't need to Enqueue() onto the TaskWait list,
97 as it is not sorted - saves quite a few cycles in
98 the long run.
100 case TS_WAIT:
101 AddTail(&SysBase->TaskWait, (struct Node *)task);
102 break;
104 case TS_REMOVED:
105 /* Ideally we should free the task here, but we can't
106 because that would corrupt the memory lists.
108 break;
110 case TS_INVALID:
111 case TS_EXCEPT:
112 case TS_RUN:
113 /* We should never be called with this state. */
114 ASSERT(FALSE);
115 break;
118 AROS_LIBFUNC_EXIT
119 } /* Reschedule */