Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / arch / i386-darwin / exec / switch.c
blob471feb6d858c8651262124845632ada7e754470d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Unix version of Switch().
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <proto/exec.h>
11 #include <proto/kernel.h>
12 #include <aros/kernel.h>
13 #include <proto/arossupport.h>
15 AROS_LH0(void, Switch,
16 struct ExecBase *, SysBase, 9, Exec)
18 AROS_LIBFUNC_INIT
20 struct Task *this = SysBase->ThisTask;
22 KRNWireImpl(SoftEnable);
23 KRNWireImpl(SoftDisable);
24 KRNWireImpl(SoftCause);
27 If the state is not TS_RUN then the task is already in a list
30 Disable();
32 if( this->tc_State != TS_RUN )
35 /* Its quite possible that they have interrupts Disabled(),
36 we should fix that here, otherwise we can't switch.
38 We can't call the dispatcher because we need a signal,
39 lets just create one.
41 Have to set the dispatch-required flag.
42 I use SIGUSR1 (maps to SoftInt) because it has less effect on
43 the system clock, and is probably quicker.
46 /* We now re-enable software interrupts. */
47 CALLHOOKPKT(krnSoftEnableImpl,0,0);
48 SysBase->AttnResched |= 0x8000;
49 CALLHOOKPKT(krnSoftCauseImpl,0,0);
50 /* Disable software interrupts */
51 CALLHOOKPKT(krnSoftDisableImpl,0,0);
55 Enable();
57 AROS_LIBFUNC_EXIT
58 } /* Switch() */