[project @ 1999-08-25 16:11:43 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Schedule.h,v 1.6 1999/08/25 16:11:51 simonmar Exp $
3  *
4  * (c) The GHC Team 1998-1999
5  *
6  * Prototypes for functions in Schedule.c 
7  * (RTS internal scheduler interface)
8  *
9  * ---------------------------------------------------------------------------*/
10
11 /* 
12  * Initialisation
13  */
14
15 void    initScheduler(void);
16
17 /* 
18  * Miscellany
19  */
20
21 void    awakenBlockedQueue(StgTSO *tso);
22 StgTSO *unblockOne(StgTSO *tso);
23 void    initThread(StgTSO *tso, nat stack_size);
24 void    interruptStgRts(void);
25 void    raiseAsync(StgTSO *tso, StgClosure *exception);
26
27 extern  nat context_switch;
28
29 void    awaitEvent(rtsBool wait);  /* In Select.c */
30 extern  nat ticks_since_select;    /* ditto */
31
32 extern  StgTSO *run_queue_hd, *run_queue_tl;
33 extern  StgTSO *blocked_queue_hd, *blocked_queue_tl;
34
35 #ifdef DEBUG
36 extern void printThreadBlockage(StgTSO *tso);
37 #endif
38
39 #ifdef COMPILING_RTS_MAIN
40 extern DLLIMPORT StgTSO *MainTSO; /* temporary hack */
41 #else
42 extern StgTSO *MainTSO; /* temporary hack */
43 #endif
44 #define END_TSO_QUEUE  ((StgTSO *)(void*)&END_TSO_QUEUE_closure)
45
46 #define PUSH_ON_RUN_QUEUE(tso)                  \
47     if (run_queue_hd == END_TSO_QUEUE) {        \
48       run_queue_hd = tso;                       \
49     } else {                                    \
50       run_queue_tl->link = tso;                 \
51     }                                           \
52     run_queue_tl = tso;
53
54 #define PUSH_ON_BLOCKED_QUEUE(tso)              \
55     if (blocked_queue_hd == END_TSO_QUEUE) {    \
56       blocked_queue_hd = tso;                   \
57     } else {                                    \
58       blocked_queue_tl->link = tso;             \
59     }                                           \
60     blocked_queue_tl = tso;
61
62 #define END_CAF_LIST  stgCast(StgCAF*,(void*)&END_TSO_QUEUE_closure)