move delay code into separate function.
[AROS.git] / rom / exec / reschedule.c
blob1c4704daebc8e843137651d189422be7d19d23eb
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Enforce task rescheduling
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <aros/atomic.h>
12 #include <hardware/intbits.h>
13 #include <proto/kernel.h>
15 #include "chipset.h"
16 #include "exec_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/exec.h>
23 AROS_LH0(void, Reschedule,
25 /* SYNOPSIS */
27 /* LOCATION */
28 struct ExecBase *, SysBase, 8, Exec)
30 /* FUNCTION
31 Give up the CPU time to other tasks (if there are any).
33 INPUTS
34 None
36 RESULT
37 None
39 NOTES
40 This function was private in AmigaOS(tm) up to v3.1. There's no guarantee
41 that it will continue to exist in other systems.
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
57 UWORD oldAttnSwitch = SysBase->AttnResched & ARF_AttnSwitch;
59 AROS_ATOMIC_OR(SysBase->AttnResched, ARF_AttnSwitch); /* Set scheduling attention */
61 if (SysBase->TDNestCnt < 0) /* If task switching enabled */
63 if (SysBase->IDNestCnt < 0) /* And interrupts enabled */
65 D(bug("[Reschedule] Calling scheduler, KernelBase 0x%p\n", KernelBase));
66 KrnSchedule(); /* Call scheduler */
68 else if (!oldAttnSwitch)
71 * Interrupts are disabled and there was no pending switch before us.
72 * Tag the software interrupt to be executed immediately after Enable().
74 CUSTOM_CAUSE(INTF_SOFTINT);
78 AROS_LIBFUNC_EXIT
79 } /* Reschedule */