summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2020-12-29 23:14:33 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-22 02:06:17 -0500
commit9943baf9b76374cb2eef53671a52fefbaed1cbce (patch)
treeda3d7fe9850aef9e8de9e2f8e40f51585c9964c3
parent3294622041192df4e9ed004097fabd70932634a4 (diff)
downloadhaskell-9943baf9b76374cb2eef53671a52fefbaed1cbce.tar.gz
Move the awaitEvent declaration into IOManager.h
And add or adjust comments at the use sites of awaitEvent.
-rw-r--r--rts/AwaitEvent.h21
-rw-r--r--rts/IOManager.h14
-rw-r--r--rts/Schedule.c32
-rw-r--r--rts/posix/Select.c2
-rw-r--r--rts/win32/AwaitEvent.c2
5 files changed, 36 insertions, 35 deletions
diff --git a/rts/AwaitEvent.h b/rts/AwaitEvent.h
deleted file mode 100644
index 92848addf2..0000000000
--- a/rts/AwaitEvent.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* -----------------------------------------------------------------------------
- *
- * (c) The GHC Team 1998-2005
- *
- * The awaitEvent() interface, for the non-threaded RTS
- *
- * -------------------------------------------------------------------------*/
-
-#pragma once
-
-#if !defined(THREADED_RTS)
-/* awaitEvent(bool wait)
- *
- * Checks for blocked threads that need to be woken.
- *
- * Called from STG : NO
- * Locks assumed : sched_mutex
- */
-RTS_PRIVATE void awaitEvent(bool wait); /* In posix/Select.c or
- * win32/AwaitEvent.c */
-#endif
diff --git a/rts/IOManager.h b/rts/IOManager.h
index 80ef84b7c2..fe65f373da 100644
--- a/rts/IOManager.h
+++ b/rts/IOManager.h
@@ -149,6 +149,20 @@ void insertIntoSleepingQueue(StgTSO *tso, LowResTime target);
INLINE_HEADER bool anyPendingTimeoutsOrIO(CapIOManager *iomgr);
+#if !defined(THREADED_RTS)
+/* Check whether there is any completed I/O or expired timers. If so,
+ * process the competions as appropriate, which will typically cause some
+ * waiting threads to be woken up.
+ *
+ * Called from schedule() both *before* and *after* scheduleDetectDeadlock().
+ *
+ * Defined in posix/Select.c
+ * or win32/AwaitEvent.c
+ */
+void awaitEvent(bool wait);
+#endif
+
+
/* Pedantic warning cleanliness
*/
#if !defined(THREADED_RTS) && defined(mingw32_HOST_OS)
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 2b25c96b71..7f9433c0ec 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -30,7 +30,6 @@
#include "Sparks.h"
#include "Capability.h"
#include "Task.h"
-#include "AwaitEvent.h"
#include "IOManager.h"
#if defined(mingw32_HOST_OS)
#include "win32/MIOManager.h"
@@ -317,6 +316,9 @@ schedule (Capability *initialCapability, Task *task)
/* Notify the I/O manager that we have nothing to do. If there are
any outstanding I/O requests we'll block here. If there are not
then this is a user error and we will abort soon. */
+ /* TODO: see if we can rationalise these two awaitEvent calls before
+ * and after scheduleDetectDeadlock().
+ */
awaitEvent (emptyRunQueue(cap));
#else
ASSERT(sched_state >= SCHED_INTERRUPTING);
@@ -900,17 +902,23 @@ static void
scheduleCheckBlockedThreads(Capability *cap USED_IF_NOT_THREADS)
{
#if !defined(THREADED_RTS)
- //
- // Check whether any waiting threads need to be woken up. If the
- // run queue is empty, and there are no other tasks running, we
- // can wait indefinitely for something to happen.
- //
- // TODO: this empty-queue test is highly dubious because it only makes
- // sense for some I/O managers. The sleeping_queue is _only_ used by the
- // select() I/O manager. The WinIO I/O manager does not use either the
- // sleeping_queue or the blocked_queue, so both queues will _always_ be
- // empty and so awaitEvent will _never_ be called here for WinIO. This may
- // explain why there is a second call to awaitEvent below for mingw32.
+ /* Check whether there is any completed I/O or expired timers. If so,
+ * process the competions as appropriate, which will typically cause some
+ * waiting threads to be woken up.
+ *
+ * If the run queue is empty, and there are no other threads running, we
+ * can wait indefinitely for something to happen.
+ *
+ * TODO: see if we can rationalise these two awaitEvent calls before
+ * and after scheduleDetectDeadlock()
+ *
+ * TODO: these empty-queue tests are highly dubious because they only make
+ * sense for some I/O managers. The sleeping_queue is _only_ used by the
+ * select() I/O manager. The WinIO I/O manager does not use either the
+ * sleeping_queue or the blocked_queue, so both queues will _always_ be
+ * empty and so awaitEvent will _never_ be called here for WinIO. This may
+ * explain why there is a second call to awaitEvent below for mingw32.
+ */
if (anyPendingTimeoutsOrIO(cap->iomgr))
{
awaitEvent (emptyRunQueue(cap));
diff --git a/rts/posix/Select.c b/rts/posix/Select.c
index f02fd63981..6c357a9982 100644
--- a/rts/posix/Select.c
+++ b/rts/posix/Select.c
@@ -19,7 +19,7 @@
#include "RtsUtils.h"
#include "Capability.h"
#include "Select.h"
-#include "AwaitEvent.h"
+#include "IOManager.h"
#include "Stats.h"
#include "GetTime.h"
diff --git a/rts/win32/AwaitEvent.c b/rts/win32/AwaitEvent.c
index 6a621d6ef5..a8bb3cd191 100644
--- a/rts/win32/AwaitEvent.c
+++ b/rts/win32/AwaitEvent.c
@@ -16,7 +16,7 @@
#include "Rts.h"
#include "RtsFlags.h"
#include "Schedule.h"
-#include "AwaitEvent.h"
+#include "IOManager.h"
#include <windows.h>
#include "win32/AsyncMIO.h"
#include "win32/AsyncWinIO.h"