2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 /*****************************************************************************
10 AROS_LH0(void, Switch,
13 struct ExecBase *, SysBase, 6, Exec)
16 Tries to switch to the first task in the ready list. This
17 function works almost like Dispatch() with the slight difference
18 that it may be called at any time and as often as you want and
19 that it does not lose the current task if it is of type TS_RUN.
26 This function is CPU dependant.
28 This function is for internal use by exec only.
30 This function preserves all registers.
43 ******************************************************************************/
49 .globl AROS_SLIB_ENTRY(Switch,Exec)
50 .type AROS_SLIB_ENTRY(Switch,Exec),@function
51 AROS_SLIB_ENTRY
(Switch
,Exec
):
52 /* call switch in supervisor mode
53 this is necessary to determine if the current context is user or
62 /* test if called from supervisor mode
63 (supervisor bit is bit 8+5 of sr when calling Switch() ) */
67 /* called from supervisor mode (grrrr)
68 since I can only Dispatch() when falling down to user mode I
69 must do it later - set the delayed dispatch flag and return */
70 bset
#7,AttnResched(a6)
73 /* Called from user mode
74 Always disable interrupts when testing task lists */
75 nosup
: move.w
#0x2700,sr
77 /* Preserve scratch registers */
78 movem.
l d0
/d1
/a0
/a1
,-(sp
)
80 /* If not in state TS_RUN the current task is part of one of the
82 move.
l ThisTask
(a6
),a1
83 cmp.
b #TS_RUN,tc_State(a1)
86 /* If TB_EXCEPT is not set... */
87 btst
#TB_EXCEPT,tc_Flags(a1)
90 /* ...Move task to the ready list */
91 move.
b #TS_READY,tc_State(a1)
92 lea.
l TaskReady
(a6
),a0
96 disp
: movem.
l (sp
)+,d0
/d1
/a0
/a1