2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
5 Desc: Forbid() - Prevent tasks switches from taking place.
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"
23 /*****************************************************************************/
27 #include <proto/exec.h>
29 AROS_LH0(void, Forbid
,
32 struct ExecBase
*, SysBase
, 22, Exec
)
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().
51 The multitasking state will be disabled AFTER this function
52 returns to the caller.
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.
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..
71 The only architecture that you can rely on the registers being
72 saved is on the Motorola mc68000 family.
75 Permit(), Disable(), Enable(), Wait()
78 If you want to preserve all the registers, replace this function
79 in your $(KERNEL) directory. Otherwise this function is
82 ******************************************************************************/
88 D(bug("[Exec] Forbid()\n"));
92 D(bug("[Exec] Forbid: TDNESTCOUNT = %d\n", TDNESTCOUNT_GET
);)