Test current SDI headers.
[AROS.git] / rom / exec / permit.c
blobcb7d47a2f60499a2239ed0c238bc16a0f9e62a50
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Permit() - Allow tasks switches to occur.
6 Lang: english
7 */
9 #define DEBUG 0
11 #include <exec/types.h>
12 #include <exec/execbase.h>
13 #include <aros/libcall.h>
14 #include <aros/atomic.h>
15 #include <aros/debug.h>
16 #include <proto/exec.h>
17 #include <proto/kernel.h>
19 #include "exec_intern.h"
21 #undef Exec
22 #ifdef UseExecstubs
23 # define Exec _Exec
24 #endif
26 /*****************************************************************************
28 NAME */
30 AROS_LH0(void, Permit,
32 /* LOCATION */
33 struct ExecBase *, SysBase, 23, Exec)
35 /* FUNCTION
36 This function will reactivate the task dispatcher after a call
37 to Forbid(). Note that calls to Forbid() nest, and for every
38 call to Forbid() you need a matching call to Permit().
40 INPUTS
41 None.
43 RESULT
44 Multitasking will be re-enabled.
46 NOTES
47 This function preserves all registers.
49 To prevent deadlocks calling Wait() in forbidden state breaks
50 the forbid - thus taskswitches may happen again.
52 EXAMPLE
53 No you really don't want to use this function.
55 BUGS
56 The only architecture that you can rely on the registers being
57 saved is on the Motorola mc68000 family.
59 SEE ALSO
60 Forbid(), Disable(), Enable(), Wait()
62 INTERNALS
63 If you want to preserve all the registers, replace this function
64 in your $(KERNEL) directory. Otherwise this function is
65 satisfactory.
67 HISTORY
70 ******************************************************************************/
71 #undef Exec
73 AROS_LIBFUNC_INIT
75 D(bug("[Exec] Permit()\n"));
78 * Task switches are allowed again, if a switch is pending, we
79 * should allow it.
81 TDNESTCOUNT_DEC;
83 D(bug("[Exec] Permit: TDNESTCOUNT = %d\n", TDNESTCOUNT_GET));
85 if (KernelBase && !KrnIsSuper())
87 if( ( TDNESTCOUNT_GET < 0 )
88 && ( IDNESTCOUNT_GET < 0 )
89 && ( FLAG_SCHEDSWITCH_ISSET ) )
92 * Haha, you re-enabled multitasking, only to have the rug
93 * pulled out from under you feet :)
95 * Clear the Switch() pending flag.
97 D(bug("[Exec] Permit: rescheduling\n"));
98 KrnSchedule();
102 AROS_LIBFUNC_EXIT
103 } /* Permit() */