[project @ 1999-09-10 11:11:51 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Schedule.h,v 1.7 1999/09/10 11:11:52 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 /* Add a thread to the end of the run queue.
47  * NOTE: tso->link should be END_TSO_QUEUE before calling this macro.
48  */
49 #define PUSH_ON_RUN_QUEUE(tso)                  \
50     if (run_queue_hd == END_TSO_QUEUE) {        \
51       run_queue_hd = tso;                       \
52     } else {                                    \
53       run_queue_tl->link = tso;                 \
54     }                                           \
55     run_queue_tl = tso;
56
57 #define PUSH_ON_BLOCKED_QUEUE(tso)              \
58     if (blocked_queue_hd == END_TSO_QUEUE) {    \
59       blocked_queue_hd = tso;                   \
60     } else {                                    \
61       blocked_queue_tl->link = tso;             \
62     }                                           \
63     blocked_queue_tl = tso;
64
65 #define END_CAF_LIST  stgCast(StgCAF*,(void*)&END_TSO_QUEUE_closure)