[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / includes / SchedAPI.h
1 /* -----------------------------------------------------------------------------
2  * $Id: SchedAPI.h,v 1.2 1998/12/02 13:21:33 simonm 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  * Running the scheduler
16  */
17
18 typedef enum {
19     Success,      
20     Killed,      /* another thread killed us                           */
21     Interrupted, /* stopped in response to a call to interruptStgRts   */
22     Deadlock,   
23     AllBlocked,  /* subtly different from Deadlock                     */
24 } SchedulerStatus;
25       
26 SchedulerStatus schedule(StgTSO *main_thread, /*out*/StgClosure **ret);
27
28 /* 
29  * Creating thraeds
30  */
31
32 StgTSO *createThread   (nat stack_size);
33
34 static inline void pushClosure   (StgTSO *tso, StgClosure *c) {
35   tso->sp--;
36   tso->sp[0] = (W_) c;
37 }
38
39 static inline void pushRealWorld (StgTSO *tso) {
40   tso->sp--;
41   tso->sp[0] = (W_) REALWORLD_TAG;
42 }
43 static inline StgTSO *
44 createGenThread(nat stack_size,  StgClosure *closure) {
45   StgTSO *t;
46   t = createThread(stack_size);
47   pushClosure(t,closure);
48   return t;
49 }
50
51 static inline StgTSO *
52 createIOThread(nat stack_size,  StgClosure *closure) {
53   StgTSO *t;
54   t = createThread(stack_size);
55   pushRealWorld(t);
56   pushClosure(t,closure);
57   return t;
58 }
59
60 /* 
61  * Killing threads
62  */
63
64 void    deleteThread(StgTSO *tso);
65
66 /*
67  * Reverting CAFs
68  */
69
70 void RevertCAFs(void);
71
72 #endif