added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / all-unix / exec / switch.c
blob2dfe296b3d3381e84c0f04c9519bee0a05a9a54a
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>
12 #include <stdlib.h>
13 #include <signal.h>
14 #include <unistd.h>
15 #include <stdio.h>
17 extern sigset_t sig_int_mask;
19 AROS_LH0(void, Switch,
20 struct ExecBase *, SysBase, 9, Exec)
22 AROS_LIBFUNC_INIT
24 struct Task *this = SysBase->ThisTask;
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 )
34 #if 0
35 if( SysBase->IDNestCnt >= 0 )
37 sigprocmask(SIG_UNBLOCK, &sig_int_mask, NULL);
39 #endif
40 sigset_t temp_sig_int_mask;
42 sigemptyset(&temp_sig_int_mask);
43 sigaddset( &temp_sig_int_mask, SIGUSR1);
45 /* Its quite possible that they have interrupts Disabled(),
46 we should fix that here, otherwise we can't switch.
48 We can't call the dispatcher because we need a signal,
49 lets just create one.
51 Have to set the dispatch-required flag.
52 I use SIGUSR1 (maps to SoftInt) because it has less effect on
53 the system clock, and is probably quicker.
56 sigprocmask(SIG_UNBLOCK, &temp_sig_int_mask, NULL);
57 SysBase->AttnResched |= 0x8000;
58 kill(getpid(), SIGUSR1);
59 sigprocmask(SIG_BLOCK, &temp_sig_int_mask, NULL);
63 Enable();
65 AROS_LIBFUNC_EXIT
66 } /* Switch() */