[project @ 2002-12-05 23:49:43 by mthomas]
[ghc-hetmet.git] / ghc / rts / Schedule.h
index 10f950c..85bece5 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Schedule.h,v 1.30 2002/03/12 11:51:07 simonmar Exp $
+ * $Id: Schedule.h,v 1.36 2002/10/22 11:01:20 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -58,6 +58,7 @@ StgTSO *unblockOne(StgTSO *tso);
  * Locks assumed   :  none
  */
 void raiseAsync(StgTSO *tso, StgClosure *exception);
+void raiseAsyncWithLock(StgTSO *tso, StgClosure *exception);
 
 /* awaitEvent()
  *
@@ -135,15 +136,8 @@ extern nat         rts_n_waiting_workers;
 extern nat         rts_n_waiting_tasks;
 #endif
 
+StgInt forkProcess(StgTSO *tso);
 
-/* Sigh, RTS-internal versions of waitThread(), scheduleThread(), and
-   rts_evalIO() for the use by main() only. ToDo: better. */
-extern SchedulerStatus waitThread_(StgTSO *tso,
-                                  /*out*/StgClosure **ret
-#if defined(THREADED_RTS)
-                                  , rtsBool blockWaiting
-#endif
-                                  );
 extern SchedulerStatus rts_mainEvalIO(HaskellObj p, /*out*/HaskellObj *ret);
 
 
@@ -189,18 +183,22 @@ typedef struct StgMainThread_ {
  */
 extern StgMainThread *main_threads;
 
+void printAllThreads(void);
+#ifdef COMPILING_SCHEDULER
+static void printThreadBlockage(StgTSO *tso);
+static void printThreadStatus(StgTSO *tso);
+#endif
 /* debugging only 
  */
 #ifdef DEBUG
-void printThreadBlockage(StgTSO *tso);
-void printThreadStatus(StgTSO *tso);
-void printAllThreads(void);
-#endif
 void print_bq (StgClosure *node);
+#endif
 #if defined(PAR)
 void print_bqe (StgBlockingQueueElement *bqe);
 #endif
 
+void labelThread(StgPtr tso, char *label);
+
 /* -----------------------------------------------------------------------------
  * Some convenient macros...
  */
@@ -267,9 +265,16 @@ void print_bqe (StgBlockingQueueElement *bqe);
 #define THREAD_RUNNABLE()  /* nothing */
 #endif
 
-/* Check whether the run queue is empty i.e. the PE is idle
+/* Check whether various thread queues are empty
  */
-#define EMPTY_RUN_QUEUE()     (run_queue_hd == END_TSO_QUEUE)
-#define EMPTY_QUEUE(q)        (q == END_TSO_QUEUE)
+#define EMPTY_QUEUE(q)         (q == END_TSO_QUEUE)
+
+#define EMPTY_RUN_QUEUE()      (EMPTY_QUEUE(run_queue_hd))
+#define EMPTY_BLOCKED_QUEUE()  (EMPTY_QUEUE(blocked_queue_hd))
+#define EMPTY_SLEEPING_QUEUE() (EMPTY_QUEUE(sleeping_queue))
+
+#define EMPTY_THREAD_QUEUES()  (EMPTY_RUN_QUEUE() && \
+                               EMPTY_BLOCKED_QUEUE() && \
+                               EMPTY_SLEEPING_QUEUE())
 
 #endif /* __SCHEDULE_H__ */