[project @ 1999-10-27 15:29:37 by simonmar]
[ghc-hetmet.git] / ghc / rts / Schedule.h
1 /* -----------------------------------------------------------------------------
2  * $Id: Schedule.h,v 1.8 1999/10/19 15:39:08 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     ASSERT(tso->link == END_TSO_QUEUE);         \
51     if (run_queue_hd == END_TSO_QUEUE) {        \
52       run_queue_hd = tso;                       \
53     } else {                                    \
54       run_queue_tl->link = tso;                 \
55     }                                           \
56     run_queue_tl = tso;
57
58 #define PUSH_ON_BLOCKED_QUEUE(tso)              \
59     ASSERT(tso->link == END_TSO_QUEUE);         \
60     if (blocked_queue_hd == END_TSO_QUEUE) {    \
61       blocked_queue_hd = tso;                   \
62     } else {                                    \
63       blocked_queue_tl->link = tso;             \
64     }                                           \
65     blocked_queue_tl = tso;
66
67 #define END_CAF_LIST  stgCast(StgCAF*,(void*)&END_TSO_QUEUE_closure)