simplerexx updated:
[AROS.git] / rom / exec / permit.c
blob152ce27d26494c64c57f5b4ca69eae9eb199b5f7
1 /*
2 Copyright © 1995-2010, 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
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 EXAMPLE
52 No you really don't want to use this function.
54 BUGS
55 The only architecture that you can rely on the registers being
56 saved is on the Motorola mc68000 family.
58 SEE ALSO
59 Forbid(), Disable(), Enable(), Wait()
61 INTERNALS
62 If you want to preserve all the registers, replace this function
63 in your $(KERNEL) directory. Otherwise this function is
64 satisfactory.
66 HISTORY
68 ******************************************************************************/
69 #undef Exec
71 AROS_LIBFUNC_INIT
74 Task switches are allowed again, if a switch is pending, we
75 should allow it.
78 AROS_ATOMIC_DEC(SysBase->TDNestCnt);
80 if( ( SysBase->TDNestCnt < 0 )
81 && ( SysBase->IDNestCnt < 0 )
82 && ( SysBase->AttnResched & 0x80 ) )
84 /* Haha, you re-enabled multitasking, only to have the rug
85 pulled out from under you feet :)
87 Clear the Switch() pending flag.
90 if (KernelBase && !KrnIsSuper()) KrnSchedule();
93 AROS_LIBFUNC_EXIT
94 } /* Permit() */