[project @ 1999-07-06 09:42:38 by sof]
[ghc-hetmet.git] / ghc / includes / SchedAPI.h
1 /* -----------------------------------------------------------------------------
2  * $Id: SchedAPI.h,v 1.6 1999/07/06 09:42:39 sof Exp $
3  *
4  * (c) The GHC Team 1998
5  *
6  * External API for the scheduler.  For most uses, the functions in
7  * RtsAPI.h should be enough.
8  *
9  * ---------------------------------------------------------------------------*/
10
11 #ifndef SCHEDAPI_H
12 #define SCHEDAPI_H
13
14 /* 
15  * schedule() plus the thread creation functions are not part
16  * part of the external RTS API, so leave them out if we're
17  * not compiling rts/ bits.   -- sof 7/99
18  * 
19  */
20 SchedulerStatus schedule(StgTSO *main_thread, /*out*/StgClosure **ret);
21
22 /* 
23  * Creating threads
24  */
25
26 StgTSO *createThread   (nat stack_size);
27
28 static inline void pushClosure   (StgTSO *tso, StgClosure *c) {
29   tso->sp--;
30   tso->sp[0] = (W_) c;
31 }
32
33 static inline void pushRealWorld (StgTSO *tso) {
34   tso->sp--;
35   tso->sp[0] = (W_) REALWORLD_TAG;
36 }
37 static inline StgTSO *
38 createGenThread(nat stack_size,  StgClosure *closure) {
39   StgTSO *t;
40   t = createThread(stack_size);
41   pushClosure(t,closure);
42   return t;
43 }
44
45 static inline StgTSO *
46 createIOThread(nat stack_size,  StgClosure *closure) {
47   StgTSO *t;
48   t = createThread(stack_size);
49   pushRealWorld(t);
50   pushClosure(t,closure);
51   return t;
52 }
53
54 /*
55  * Same as above, but also evaluate the result of the IO action
56  * to whnf while we're at it.
57  */
58
59 static inline StgTSO *
60 createStrictIOThread(nat stack_size,  StgClosure *closure) {
61   StgTSO *t;
62   t = createThread(stack_size);
63   pushClosure(t,closure);
64   pushClosure(t,(StgClosure*)&forceIO_closure);
65   return t;
66 }
67
68
69 /* 
70  * Killing threads
71  */
72
73 void    deleteThread(StgTSO *tso);
74
75 /*
76  * Reverting CAFs
77  */
78
79 void RevertCAFs(void);
80
81 #endif