adapted to new ResetSpin parameter
[aros:aros.git] / AROS / rom / kernel / scheduling.c
1 /*
2     Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3     $Id$
4
5     Desc:
6 */
7
8 #include <aros/kernel.h>
9 #include <aros/libcall.h>
10 #include <aros/atomic.h>
11
12 #include <proto/kernel.h>
13 #include <proto/exec.h>
14
15 #include "exec_intern.h"
16
17 #include <kernel_base.h>
18 #define DEBUG 1
19 #include <aros/debug.h>
20
21 /*****************************************************************************
22
23     NAME */
24 #include <proto/kernel.h>
25
26         AROS_LH1(BYTE, KrnScheduling,
27             AROS_LHA(LONG, trigger, D0),
28
29 /*  SYNOPSIS */
30
31 /*  LOCATION */
32     struct KernelBase *, KernelBase, 43, Kernel)
33
34 /*  FUNCTION
35     Alter kernel task switching
36
37     INPUTS
38     None
39
40     RESULT
41
42     NOTES
43     This does nothing on uni-processor systems
44     KSCHED_FORBID/KSCHED_PERMIT increase/decrease SysBase->TDNestCnt
45     themselves. No need to manually set SysBase->TDNestCnt afterwards.
46
47     EXAMPLE
48
49     BUGS
50
51     SEE ALSO
52
53     INTERNALS
54
55 ******************************************************************************/
56 {
57     AROS_LIBFUNC_INIT
58
59     /* The actual implementation can be entirely architecture-specific */
60     switch (trigger) {
61     case KSCHED_INSPECT: break;
62     case KSCHED_FORBID: AROS_ATOMIC_INC(SysBase->TDNestCnt); break;
63     case KSCHED_PERMIT: AROS_ATOMIC_DEC(SysBase->TDNestCnt); break;
64     default:            SysBase->TDNestCnt = (BYTE)trigger; 
65                         D(bug("[SCHEDULE] force TDNestCnt to %d\n", trigger));
66                         if(trigger==-1)
67                         {
68                             ResetSpin(&(PrivExecBase(SysBase)->LibList_spinlock), 1);
69                         }
70                         else
71                         {
72                             bug("[SCHEDULE] WARNING: trigger %d not supported!\n", trigger);
73                         }
74                         break;
75     }
76
77     return SysBase->TDNestCnt;
78
79     AROS_LIBFUNC_EXIT
80 }