summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2021-12-14 16:13:51 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-22 02:06:17 -0500
commit39a91f60d958247cffdd6e10ac58030bc72ce464 (patch)
tree1e294d5bba420be2f6b895dd7025fad16bcf00b7 /rts
parent0f68919ee6ef7ed77c79008e9e807d39919fadc0 (diff)
downloadhaskell-39a91f60d958247cffdd6e10ac58030bc72ce464.tar.gz
Move macros for checking for pending IO or timers
from Schedule.h to Schedule.c and IOManager.h This is just moving, the next step will be to rejig them slightly. For the non-threaded RTS the scheduler needs to be able to test for there being pending I/O operation or pending timers. The implementation of these tests should really be considered to be part of the I/O managers and not part of the scheduler.
Diffstat (limited to 'rts')
-rw-r--r--rts/IOManager.h15
-rw-r--r--rts/Schedule.c14
-rw-r--r--rts/Schedule.h16
3 files changed, 29 insertions, 16 deletions
diff --git a/rts/IOManager.h b/rts/IOManager.h
index 515cfc2f85..72bfac1fb0 100644
--- a/rts/IOManager.h
+++ b/rts/IOManager.h
@@ -155,5 +155,20 @@ void insertIntoSleepingQueue(StgTSO *tso, LowResTime target);
#define USED_IF_THREADS_AND_NOT_MINGW32 STG_UNUSED
#endif
+/* -----------------------------------------------------------------------------
+ * INLINE functions... private from here on down.
+ *
+ * Some of these hooks are performance sensitive so parts of them are
+ * implemented here so they can be inlined.
+ * -----------------------------------------------------------------------------
+ */
+
+/* TODO: rename and replace these macros by inline functions
+ * these have been moved here from Scheduler.h
+ */
+#if !defined(THREADED_RTS)
+#define EMPTY_BLOCKED_QUEUE(cap) (emptyQueue(cap->iomgr->blocked_queue_hd))
+#define EMPTY_SLEEPING_QUEUE(cap) (emptyQueue(cap->iomgr->sleeping_queue))
+#endif
#include "EndPrivate.h"
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 67e2ff4ee8..5d3789c31d 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -143,6 +143,7 @@ static void startWorkerTasks (uint32_t from USED_IF_THREADS,
#endif
static void scheduleStartSignalHandlers (Capability *cap);
static void scheduleCheckBlockedThreads (Capability *cap);
+static bool emptyThreadQueues(Capability *cap);
static void scheduleProcessInbox(Capability **cap);
static void scheduleDetectDeadlock (Capability **pcap, Task *task);
static void schedulePushWork(Capability *cap, Task *task);
@@ -167,6 +168,7 @@ static void deleteAllThreads (void);
static void deleteThread_(StgTSO *tso);
#endif
+
/* ---------------------------------------------------------------------------
Main scheduling loop.
@@ -916,6 +918,18 @@ scheduleCheckBlockedThreads(Capability *cap USED_IF_NOT_THREADS)
#endif
}
+static bool
+emptyThreadQueues(Capability *cap)
+{
+ return emptyRunQueue(cap)
+#if !defined(THREADED_RTS)
+ // TODO replace this by a test that deferrs to the active I/O manager
+ && EMPTY_BLOCKED_QUEUE(cap) && EMPTY_SLEEPING_QUEUE(cap)
+#endif
+ ;
+}
+
+
/* ----------------------------------------------------------------------------
* Detect deadlock conditions and attempt to resolve them.
* ------------------------------------------------------------------------- */
diff --git a/rts/Schedule.h b/rts/Schedule.h
index 64f9f7d166..b0898b9a4c 100644
--- a/rts/Schedule.h
+++ b/rts/Schedule.h
@@ -174,22 +174,6 @@ truncateRunQueue(Capability *cap)
cap->n_run_queue = 0;
}
-#if !defined(THREADED_RTS)
-#define EMPTY_BLOCKED_QUEUE(cap) (emptyQueue(cap->iomgr->blocked_queue_hd))
-#define EMPTY_SLEEPING_QUEUE(cap) (emptyQueue(cap->iomgr->sleeping_queue))
-#endif
-
-INLINE_HEADER bool
-emptyThreadQueues(Capability *cap)
-{
- return emptyRunQueue(cap)
-#if !defined(THREADED_RTS)
- // TODO replace this by a test that deferrs to the active I/O manager
- && EMPTY_BLOCKED_QUEUE(cap) && EMPTY_SLEEPING_QUEUE(cap)
-#endif
- ;
-}
-
#endif /* !IN_STG_CODE */
#include "EndPrivate.h"