2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Permit() - Allow tasks switches to occur.
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"
25 /*****************************************************************************
29 AROS_LH0(void, Permit
,
32 struct ExecBase
*, SysBase
, 23, Exec
)
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().
43 Multitasking will be re-enabled.
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.
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..
62 The only architecture that you can rely on the registers being
63 saved is on the Motorola mc68000 family.
66 Forbid(), Disable(), Enable(), Wait()
69 If you want to preserve all the registers, replace this function
70 in your $(KERNEL) directory. Otherwise this function is
76 ******************************************************************************/
81 D(bug("[Exec] Permit()\n"));
84 * Task switches are allowed again, if a switch is pending, we
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"));