/* -----------------------------------------------------------------------------
- * $Id: Schedule.h,v 1.31 2002/03/12 13:57:12 simonmar Exp $
+ * $Id: Schedule.h,v 1.38 2003/03/17 14:47:48 simonmar Exp $
*
* (c) The GHC Team 1998-1999
*
void awakenBlockedQueue(StgBlockingQueueElement *q, StgClosure *node);
#else
void awakenBlockedQueue(StgTSO *tso);
+#if defined(RTS_SUPPORTS_THREADS)
+void awakenBlockedQueueNoLock(StgTSO *tso);
+#endif
#endif
/* unblockOne()
* Locks assumed : none
*/
void raiseAsync(StgTSO *tso, StgClosure *exception);
+void raiseAsyncWithLock(StgTSO *tso, StgClosure *exception);
-/* awaitEvent()
+/* awaitEvent(rtsBool wait)
*
- * Raises an exception asynchronously in the specified thread.
+ * Checks for blocked threads that need to be woken.
*
* Called from STG : NO
* Locks assumed : sched_mutex
*/
rtsBool wakeUpSleepingThreads(nat); /* In Select.c */
+/* wakeBlockedWorkerThread()
+ *
+ * If a worker thread is currently blocked in awaitEvent(), interrupt it.
+ *
+ * Called from STG : NO
+ * Locks assumed : sched_mutex
+ */
+void wakeBlockedWorkerThread(void); /* In Select.c */
+
+
/* GetRoots(evac_fn f)
*
* Call f() for each root known to the scheduler.
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);
+extern SchedulerStatus rts_mainLazyIO(HaskellObj p, /*out*/HaskellObj *ret);
/* Called by shutdown_handler(). */
StgClosure ** ret;
#if defined(RTS_SUPPORTS_THREADS)
Condition wakeup;
+#if defined(THREADED_RTS)
+ rtsBool thread_bound;
+ Condition bound_thread_cond;
+#endif
#endif
struct StgMainThread_ *link;
} 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...
*/
*/
#if defined(RTS_SUPPORTS_THREADS)
#define THREAD_RUNNABLE() \
- if ( !noCapabilities() ) { \
- signalCondition(&thread_ready_cond); \
- } \
+ wakeBlockedWorkerThread(); \
context_switch = 1;
#else
#define THREAD_RUNNABLE() /* nothing */
EMPTY_BLOCKED_QUEUE() && \
EMPTY_SLEEPING_QUEUE())
+#if defined(RTS_SUPPORTS_THREADS)
+/* If no task is waiting for a capability,
+ * spawn a new worker thread.
+ *
+ * (Used by the RtsAPI)
+ */
+void
+startSchedulerTask(void);
+#endif
+
#endif /* __SCHEDULE_H__ */