revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / forbid.c
blob53a0c25aaa34bf0cada5720d6aa9851f227fcae5
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Forbid() - Prevent tasks switches from taking place.
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>
16 #include "exec_intern.h"
18 #undef Exec
19 #ifdef UseExecstubs
20 # define Exec _Exec
21 #endif
23 /*****************************************************************************/
26 /* NAME */
27 #include <proto/exec.h>
29 AROS_LH0(void, Forbid,
31 /* LOCATION */
32 struct ExecBase *, SysBase, 22, Exec)
34 /* FUNCTION
35 Forbid any further taskswitches (*) until a matching call to Permit().
36 Naturally disabling taskswitches means:
38 THIS CALL IS DANGEROUS
40 Do not use it without thinking very well about it or better
41 do not use it at all. Most of the time you can live without
42 it by using semaphores or similar.
44 Calls to Forbid() nest, i.e. for each call to Forbid() you
45 need one call to Permit().
47 INPUTS
48 None.
50 RESULT
51 The multitasking state will be disabled AFTER this function
52 returns to the caller.
54 NOTES
55 This function preserves all registers.
57 To prevent deadlocks calling Wait() in forbidden state breaks
58 the forbid - thus taskswitches may happen again.
60 (*) On EXECSMP builds, Forbid() only aplies to the processor
61 it is called from. Data which needs to be protected from
62 parallel access will also require a spinlock.
64 EXAMPLE
65 On uniprocessor builds of AROS, it is generally not necessary/
66 desirable to use Forbid()/Permit() in most userspace code - however for
67 EXECSMP builds, you will need to protect spinlocks against
68 task switches on the local processor..
70 BUGS
71 The only architecture that you can rely on the registers being
72 saved is on the Motorola mc68000 family.
74 SEE ALSO
75 Permit(), Disable(), Enable(), Wait()
77 INTERNALS
78 If you want to preserve all the registers, replace this function
79 in your $(KERNEL) directory. Otherwise this function is
80 satisfactory.
82 ******************************************************************************/
84 #undef Exec
86 AROS_LIBFUNC_INIT
88 D(bug("[Exec] Forbid()\n"));
90 TDNESTCOUNT_INC;
92 D(bug("[Exec] Forbid: TDNESTCOUNT = %d\n", TDNESTCOUNT_GET);)
94 AROS_LIBFUNC_EXIT
95 } /* Forbid() */