[project @ 2002-02-04 20:21:16 by sof]
[ghc-hetmet.git] / ghc / rts / Schedule.h
index 219ca90..b81087d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Schedule.h,v 1.16 2000/03/16 17:27:13 simonmar Exp $
+ * $Id: Schedule.h,v 1.25 2001/11/22 14:25:12 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -58,10 +58,8 @@ void awakenBlockedQueue(StgTSO *tso);
  * Called from STG : yes
  * Locks assumed   : none
  */
-#if defined(GRAN)
-StgTSO *unblockOne(StgTSO *tso, StgClosure *node);
-#elif defined(PAR)
-StgTSO *unblockOne(StgTSO *tso, StgClosure *node);
+#if defined(GRAN) || defined(PAR)
+StgBlockingQueueElement *unblockOne(StgBlockingQueueElement *bqe, StgClosure *node);
 #else
 StgTSO *unblockOne(StgTSO *tso);
 #endif
@@ -86,6 +84,24 @@ void raiseAsync(StgTSO *tso, StgClosure *exception);
  */
 void awaitEvent(rtsBool wait);  /* In Select.c */
 
+/* wakeUpSleepingThreads(nat ticks)
+ *
+ * Wakes up any sleeping threads whose timers have expired.
+ *
+ * Called from STG :  NO
+ * Locks assumed   :  sched_mutex
+ */
+rtsBool wakeUpSleepingThreads(nat);  /* In Select.c */
+
+/* GetRoots(evac_fn f)
+ *
+ * Call f() for each root known to the scheduler.
+ *
+ * Called from STG :  NO
+ * Locks assumed   :  ????
+ */
+void GetRoots(evac_fn);
+
 // ToDo: check whether all fcts below are used in the SMP version, too
 //@cindex awaken_blocked_queue
 #if defined(GRAN)
@@ -113,12 +129,8 @@ void    initThread(StgTSO *tso, nat stack_size);
 extern nat context_switch;
 extern rtsBool interrupted;
 
-extern  nat ticks_since_select;
-
-//@cindex Capability
-/* Capability type
- */
-typedef StgRegTable Capability;
+/* In Select.c */
+extern nat timestamp;
 
 /* Free capability list.
  * Locks required: sched_mutex.
@@ -127,14 +139,22 @@ typedef StgRegTable Capability;
 extern Capability *free_capabilities;
 extern nat n_free_capabilities;
 #else
-extern Capability MainRegTable;
+extern Capability MainCapability;
 #endif
 
 /* Thread queues.
  * Locks required  : sched_mutex
+ *
+ * In GranSim we have one run/blocked_queue per PE.
  */
+#if defined(GRAN)
+// run_queue_hds defined in GranSim.h
+#else
 extern  StgTSO *run_queue_hd, *run_queue_tl;
 extern  StgTSO *blocked_queue_hd, *blocked_queue_tl;
+extern  StgTSO *sleeping_queue;
+#endif
+/* Linked list of all threads. */
 extern  StgTSO *all_threads;
 
 #ifdef SMP
@@ -160,16 +180,10 @@ typedef struct {
 extern task_info *task_ids;
 #endif
 
-#if !defined(GRAN)
-extern  StgTSO *run_queue_hd, *run_queue_tl;
-extern  StgTSO *blocked_queue_hd, *blocked_queue_tl;
-#endif
-
 /* Needed by Hugs.
  */
 void interruptStgRts ( void );
 
-// ?? needed -- HWL
 void raiseAsync(StgTSO *tso, StgClosure *exception);
 nat  run_queue_len(void);
 
@@ -186,13 +200,15 @@ void printThreadStatus(StgTSO *tso);
 void printAllThreads(void);
 #endif
 void print_bq (StgClosure *node);
+#if defined(PAR)
+void print_bqe (StgBlockingQueueElement *bqe);
+#endif
 
 /* -----------------------------------------------------------------------------
  * Some convenient macros...
  */
 
-#define END_TSO_QUEUE  ((StgTSO *)(void*)&END_TSO_QUEUE_closure)
-#define END_CAF_LIST   ((StgCAF *)(void*)&END_TSO_QUEUE_closure)
+/* END_TSO_QUEUE and friends now defined in includes/StgMiscClosures.h */
 
 //@cindex APPEND_TO_RUN_QUEUE
 /* Add a thread to the end of the run queue.
@@ -218,7 +234,7 @@ void print_bq (StgClosure *node);
       run_queue_tl = tso;                      \
     }
 
-//@cindex POP_RUN_QUEUE    
+//@cindex POP_RUN_QUEUE
 /* Pop the first thread off the runnable queue.
  */
 #define POP_RUN_QUEUE()                                \
@@ -259,6 +275,11 @@ void print_bq (StgClosure *node);
 #define THREAD_RUNNABLE()  /* nothing */
 #endif
 
+//@cindex EMPTY_RUN_QUEUE
+/* Check whether the run queue is empty i.e. the PE is idle
+ */
+#define EMPTY_RUN_QUEUE()     (run_queue_hd == END_TSO_QUEUE)
+
 //@node Index,  , Some convenient macros
 //@subsection Index