1 /* -----------------------------------------------------------------------------
2 * $Id: SchedAPI.h,v 1.13 2001/03/22 03:51:09 hwloidl Exp $
4 * (c) The GHC Team 1998
6 * External API for the scheduler. For most uses, the functions in
7 * RtsAPI.h should be enough.
9 * ---------------------------------------------------------------------------*/
15 // Dummy def for NO_PRI if not in GranSim
20 * schedule() plus the thread creation functions are not part
21 * part of the external RTS API, so leave them out if we're
22 * not compiling rts/ bits. -- sof 7/99
25 SchedulerStatus waitThread(StgTSO *main_thread, /*out*/StgClosure **ret);
31 StgTSO *createThread(nat stack_size, StgInt pri);
33 StgTSO *createThread(nat stack_size);
35 #if defined(PAR) || defined(SMP)
38 void scheduleThread(StgTSO *tso);
40 static inline void pushClosure (StgTSO *tso, StgClosure *c) {
45 static inline void pushRealWorld (StgTSO *tso) {
47 tso->sp[0] = (W_) REALWORLD_TAG;
49 static inline StgTSO *
50 createGenThread(nat stack_size, StgClosure *closure) {
53 t = createThread(stack_size, NO_PRI);
55 t = createThread(stack_size);
57 pushClosure(t,closure);
61 static inline StgTSO *
62 createIOThread(nat stack_size, StgClosure *closure) {
65 t = createThread(stack_size, NO_PRI);
67 t = createThread(stack_size);
70 pushClosure(t,closure);
75 * Same as above, but also evaluate the result of the IO action
76 * to whnf while we're at it.
79 static inline StgTSO *
80 createStrictIOThread(nat stack_size, StgClosure *closure) {
83 t = createThread(stack_size, NO_PRI);
85 t = createThread(stack_size);
87 pushClosure(t,closure);
88 pushClosure(t,(StgClosure*)&stg_forceIO_closure);
96 extern void deleteThread(StgTSO *tso);
97 extern void deleteAllThreads ( void );
98 extern int howManyThreadsAvail ( void );
100 * Run until there are no more threads.
102 extern void finishAllThreads ( void );
107 extern void RevertCAFs ( void );