2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Exec function Switch
9 /******************************************************************************
13 AROS_LH0(void, Switch,
16 struct ExecBase *, SysBase, 9, Exec)
19 Tries to switch to the first task in the ready list. This
20 function works almost like Dispatch() with the slight difference
21 that it may be called at any time and as often as you want and
22 that it does not lose the current task if it is of type TS_RUN.
30 This function is CPU dependant.
32 This function is for internal use by exec only.
34 This function preserves all registers.
47 ******************************************************************************/
53 .globl AROS_SLIB_ENTRY(Switch,Exec)
54 .type AROS_SLIB_ENTRY(Switch,Exec),@function
55 AROS_SLIB_ENTRY
(Switch
,Exec
):
56 /* Check to see if we are called from supervisor */
57 tst.
b AROS_CSYMNAME
(supervisor
)
60 /* Called from supervisor mode - set the delayed dispatch flag
66 bset
#7,AttnResched(%a6)
72 /* Called from user mode */
74 /* Preserve scratch registers */
75 movem.
l %d0-
%d1
/%a0-
%a1
,-(%sp
)
77 /* Always disable interrupts when testing task lists */
78 jbsr AROS_CSYMNAME
(os_disable
)
83 /* If not in state TS_RUN the current task is already moved
84 to one of the task lists. */
85 move.
l ThisTask
(%a0
),%a1
87 move.
l ThisTask
(%a6
),%a1
89 cmpi.
b #TS_RUN,tc_State(%a1)
92 /* If TB_EXCEPT is not set... */
93 btst
#TB_EXCEPT,tc_Flags(%a1)
96 /* ...move task to the ready list */
97 move.
b #TS_READY,tc_State(%a1)
106 lea.
l TaskReady
(%a6
),%a0
111 .disp: movem.l (%sp)+,%d0-%d1/%a0-%a1
113 jmp AROS_SLIB_ENTRY
(Dispatch
,Exec
)