2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Reschedule() - Put a task back into the ready or waiting list.
9 #include <aros/debug.h>
10 #include <exec/types.h>
11 #include <exec/execbase.h>
12 #include <aros/libcall.h>
14 /*****i***********************************************************************
17 #include <proto/exec.h>
19 AROS_LH1(void, Reschedule
,
22 AROS_LHA(struct Task
*, task
, A0
),
25 struct ExecBase
*, SysBase
, 8, Exec
)
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
33 It is possible that in the future, more efficient schedulers
34 will be implemented. In which case this is the function that they
37 You should not do any costly calculations since you will be
38 running in interupt mode.
41 task - The task to insert into the list.
44 The task will be inserted into one of Exec's task lists.
47 Not actually complete yet. Some of the task states don't have any
53 Only in relation to the comments within about low-priority tasks
54 not getting any processor time.
60 ******************************************************************************/
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
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
)
88 Enqueue(&SysBase
->TaskReady
, (struct Node
*)task
);
92 Enqueue(&SysBase
->TaskReady
, (struct Node
*)task
);
96 We don't need to Enqueue() onto the TaskWait list,
97 as it is not sorted - saves quite a few cycles in
101 AddTail(&SysBase
->TaskWait
, (struct Node
*)task
);
105 /* Ideally we should free the task here, but we can't
106 because that would corrupt the memory lists.
113 /* We should never be called with this state. */