revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / permit.c
blobe48b5d692e73cbf908ab5d498423c84b3ea50f6f
1 /*
2 Copyright © 1995-2017, 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>
18 #include "exec_intern.h"
20 #undef Exec
21 #ifdef UseExecstubs
22 # define Exec _Exec
23 #endif
25 /*****************************************************************************
27 NAME */
29 AROS_LH0(void, Permit,
31 /* LOCATION */
32 struct ExecBase *, SysBase, 23, Exec)
34 /* FUNCTION
35 This function will reactivate the task dispatcher (*) after a call
36 to Forbid(). Note that calls to Forbid() nest, and for every
37 call to Forbid() you need a matching call to Permit().
39 INPUTS
40 None.
42 RESULT
43 Multitasking will be re-enabled.
45 NOTES
46 This function preserves all registers.
48 To prevent deadlocks calling Wait() in forbidden state breaks
49 the forbid - thus taskswitches may happen again.
51 (*) On EXECSMP builds, Forbid() only aplies to the processor
52 it is called from. Data which needs to be protected from
53 parallel access will also require a spinlock.
55 EXAMPLE
56 On uniprocessor builds of AROS, it is generally not necessary/
57 desirable to use Forbid()/Permit() in most userspace code - however for
58 EXECSMP builds, you will need to protect spinlocks against
59 task switches on the local processor..
61 BUGS
62 The only architecture that you can rely on the registers being
63 saved is on the Motorola mc68000 family.
65 SEE ALSO
66 Forbid(), Disable(), Enable(), Wait()
68 INTERNALS
69 If you want to preserve all the registers, replace this function
70 in your $(KERNEL) directory. Otherwise this function is
71 satisfactory.
73 HISTORY
76 ******************************************************************************/
77 #undef Exec
79 AROS_LIBFUNC_INIT
81 D(bug("[Exec] Permit()\n"));
84 * Task switches are allowed again, if a switch is pending, we
85 * should allow it.
87 TDNESTCOUNT_DEC;
89 D(bug("[Exec] Permit: TDNESTCOUNT = %d\n", TDNESTCOUNT_GET));
91 if (KernelBase && !KrnIsSuper())
93 if( ( TDNESTCOUNT_GET < 0 )
94 && ( IDNESTCOUNT_GET < 0 )
95 && ( FLAG_SCHEDSWITCH_ISSET ) )
98 * Haha, you re-enabled multitasking, only to have the rug
99 * pulled out from under you feet :)
101 * Clear the Switch() pending flag.
103 D(bug("[Exec] Permit: rescheduling\n"));
104 KrnSchedule();
108 AROS_LIBFUNC_EXIT
109 } /* Permit() */