1 /* -----------------------------------------------------------------------------
2 * $Id: SchedAPI.h,v 1.10 2000/04/14 15:18:05 sewardj 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 void scheduleThread(StgTSO *tso);
37 static inline void pushClosure (StgTSO *tso, StgClosure *c) {
42 static inline void pushRealWorld (StgTSO *tso) {
44 tso->sp[0] = (W_) REALWORLD_TAG;
46 static inline StgTSO *
47 createGenThread(nat stack_size, StgClosure *closure) {
50 t = createThread(stack_size, NO_PRI);
52 t = createThread(stack_size);
54 pushClosure(t,closure);
58 static inline StgTSO *
59 createIOThread(nat stack_size, StgClosure *closure) {
62 t = createThread(stack_size, NO_PRI);
64 t = createThread(stack_size);
67 pushClosure(t,closure);
72 * Same as above, but also evaluate the result of the IO action
73 * to whnf while we're at it.
76 static inline StgTSO *
77 createStrictIOThread(nat stack_size, StgClosure *closure) {
80 t = createThread(stack_size, NO_PRI);
82 t = createThread(stack_size);
84 pushClosure(t,closure);
85 pushClosure(t,(StgClosure*)&forceIO_closure);
93 extern void deleteThread(StgTSO *tso);
94 extern void deleteAllThreads ( void );
95 extern int howManyThreadsAvail ( void );
97 * Run until there are no more threads.
99 extern void finishAllThreads ( void );
104 extern void RevertCAFs ( void );