use GET_THIS_TASK internally throughout exec - since it will result in faster/smaller...
[AROS.git] / rom / exec / permit.c
blobb5dcd9ab29ee04c7ec13ed0e9e168dd4835c7d24
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 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <aros/atomic.h>
13 #include <aros/debug.h>
14 #include <proto/exec.h>
15 #include <proto/kernel.h>
17 #include "exec_intern.h"
19 #undef Exec
20 #ifdef UseExecstubs
21 # define Exec _Exec
22 #endif
24 /*****************************************************************************
26 NAME */
28 AROS_LH0(void, Permit,
30 /* LOCATION */
31 struct ExecBase *, SysBase, 23, Exec)
33 /* FUNCTION
34 This function will reactivate the task dispatcher after a call
35 to Forbid(). Note that calls to Forbid() nest, and for every
36 call to Forbid() you need a matching call to Permit().
38 INPUTS
39 None.
41 RESULT
42 Multitasking will be re-enabled.
44 NOTES
45 This function preserves all registers.
47 To prevent deadlocks calling Wait() in forbidden state breaks
48 the forbid - thus taskswitches may happen again.
50 EXAMPLE
51 No you really don't want to use this function.
53 BUGS
54 The only architecture that you can rely on the registers being
55 saved is on the Motorola mc68000 family.
57 SEE ALSO
58 Forbid(), Disable(), Enable(), Wait()
60 INTERNALS
61 If you want to preserve all the registers, replace this function
62 in your $(KERNEL) directory. Otherwise this function is
63 satisfactory.
65 HISTORY
68 ******************************************************************************/
69 #undef Exec
71 AROS_LIBFUNC_INIT
73 D(bug("[EXEC] Permit()\n"));
76 Task switches are allowed again, if a switch is pending, we
77 should allow it.
79 TDNESTCOUNT_DEC;
81 if( ( TDNESTCOUNT_GET < 0 )
82 && ( IDNESTCOUNT_GET < 0 )
83 && ( FLAG_SCHEDSWITCH_ISSET ) )
85 /* Haha, you re-enabled multitasking, only to have the rug
86 pulled out from under you feet :)
88 Clear the Switch() pending flag.
91 if (KernelBase && !KrnIsSuper()) KrnSchedule();
94 AROS_LIBFUNC_EXIT
95 } /* Permit() */