use new platform macros to access scheduling/per-cpu flags. fix execsmp wait()
[AROS.git] / rom / exec / forbid.c
blob2ac5c9c2e995ab19527eac851346a98f69cd530f
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Forbid() - Prevent tasks switches from taking place.
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 <exec_platform.h>
15 /*****************************************************************************/
16 #undef Exec
17 #ifdef UseExecstubs
18 # define Exec _Exec
19 #endif
21 /* NAME */
22 #include <proto/exec.h>
24 AROS_LH0(void, Forbid,
26 /* LOCATION */
27 struct ExecBase *, SysBase, 22, Exec)
29 /* FUNCTION
30 Forbid any further taskswitches until a matching call to Permit().
31 Naturally disabling taskswitches means:
33 THIS CALL IS DANGEROUS
35 Do not use it without thinking very well about it or better
36 do not use it at all. Most of the time you can live without
37 it by using semaphores or similar.
39 Calls to Forbid() nest, i.e. for each call to Forbid() you
40 need one call to Permit().
42 INPUTS
43 None.
45 RESULT
46 The multitasking state will be disabled AFTER this function
47 returns to the caller.
49 NOTES
50 This function preserves all registers.
52 To prevent deadlocks calling Wait() in forbidden state breaks
53 the forbid - thus taskswitches may happen again.
55 EXAMPLE
56 No you really don't want to use this function.
58 BUGS
59 The only architecture that you can rely on the registers being
60 saved is on the Motorola mc68000 family.
62 SEE ALSO
63 Permit(), Disable(), Enable(), Wait()
65 INTERNALS
66 If you want to preserve all the registers, replace this function
67 in your $(KERNEL) directory. Otherwise this function is
68 satisfactory.
70 ******************************************************************************/
72 #undef Exec
74 AROS_LIBFUNC_INIT
76 TDNESTCOUNT_INC;
78 AROS_LIBFUNC_EXIT
79 } /* Forbid() */