use GET_THIS_TASK internally throughout exec - since it will result in faster/smaller...
[AROS.git] / rom / exec / forbid.c
blob505ccb794003c992baf6288d46166d8507000ba4
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>
14 #include "exec_intern.h"
16 #undef Exec
17 #ifdef UseExecstubs
18 # define Exec _Exec
19 #endif
21 /*****************************************************************************
24 /* NAME */
25 #include <proto/exec.h>
27 AROS_LH0(void, Forbid,
29 /* LOCATION */
30 struct ExecBase *, SysBase, 22, Exec)
32 /* FUNCTION
33 Forbid any further taskswitches until a matching call to Permit().
34 Naturally disabling taskswitches means:
36 THIS CALL IS DANGEROUS
38 Do not use it without thinking very well about it or better
39 do not use it at all. Most of the time you can live without
40 it by using semaphores or similar.
42 Calls to Forbid() nest, i.e. for each call to Forbid() you
43 need one call to Permit().
45 INPUTS
46 None.
48 RESULT
49 The multitasking state will be disabled AFTER this function
50 returns to the caller.
52 NOTES
53 This function preserves all registers.
55 To prevent deadlocks calling Wait() in forbidden state breaks
56 the forbid - thus taskswitches may happen again.
58 EXAMPLE
59 No you really don't want to use this function.
61 BUGS
62 The only architecture that you can rely on the registers being
63 saved is on the Motorola mc68000 family.
65 SEE ALSO
66 Permit(), Disable(), Enable(), Wait()
68 INTERNALS
69 If you want to preserve all the registers, replace this function
70 in your $(KERNEL) directory. Otherwise this function is
71 satisfactory.
73 ******************************************************************************/
75 #undef Exec
77 AROS_LIBFUNC_INIT
79 D(bug("[EXEC] Forbid()\n"));
81 TDNESTCOUNT_INC;
83 AROS_LIBFUNC_EXIT
84 } /* Forbid() */