summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2020-12-30 00:29:44 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-22 02:06:17 -0500
commit667fe5a471378124fecc149373bb25bf16771d17 (patch)
tree7f521b70746fc79d82ba04ef00374a6198f997e7
parent054dcc9ddf6ff01245d356d6d87ad97fec30f47d (diff)
downloadhaskell-667fe5a471378124fecc149373bb25bf16771d17.tar.gz
Pass the Capability *cap explicitly to appendToIOBlockedQueue
And to insertIntoSleepingQueue. Again, it's a bit cleaner and simpler though not strictly necessary given that these primops are currently only used in the non-threaded RTS.
-rw-r--r--rts/IOManager.c20
-rw-r--r--rts/IOManager.h4
-rw-r--r--rts/PrimOps.cmm14
3 files changed, 20 insertions, 18 deletions
diff --git a/rts/IOManager.c b/rts/IOManager.c
index b4ce11ff76..21407a7814 100644
--- a/rts/IOManager.c
+++ b/rts/IOManager.c
@@ -187,21 +187,23 @@ setIOManagerControlFd(uint32_t cap_no USED_IF_THREADS, int fd USED_IF_THREADS) {
#endif
#if !defined(THREADED_RTS)
-void appendToIOBlockedQueue(StgTSO *tso)
+void appendToIOBlockedQueue(Capability *cap, StgTSO *tso)
{
+ CapIOManager *iomgr = cap->iomgr;
ASSERT(tso->_link == END_TSO_QUEUE);
- if (MainCapability.iomgr->blocked_queue_hd == END_TSO_QUEUE) {
- MainCapability.iomgr->blocked_queue_hd = tso;
+ if (iomgr->blocked_queue_hd == END_TSO_QUEUE) {
+ iomgr->blocked_queue_hd = tso;
} else {
- setTSOLink(&MainCapability, MainCapability.iomgr->blocked_queue_tl, tso);
+ setTSOLink(cap, iomgr->blocked_queue_tl, tso);
}
- MainCapability.iomgr->blocked_queue_tl = tso;
+ iomgr->blocked_queue_tl = tso;
}
-void insertIntoSleepingQueue(StgTSO *tso, LowResTime target)
+void insertIntoSleepingQueue(Capability *cap, StgTSO *tso, LowResTime target)
{
+ CapIOManager *iomgr = cap->iomgr;
StgTSO *prev = NULL;
- StgTSO *t = MainCapability.iomgr->sleeping_queue;
+ StgTSO *t = iomgr->sleeping_queue;
while (t != END_TSO_QUEUE && t->block_info.target < target) {
prev = t;
t = t->_link;
@@ -209,9 +211,9 @@ void insertIntoSleepingQueue(StgTSO *tso, LowResTime target)
tso->_link = t;
if (prev == NULL) {
- MainCapability.iomgr->sleeping_queue = tso;
+ iomgr->sleeping_queue = tso;
} else {
- setTSOLink(&MainCapability, prev, tso);
+ setTSOLink(cap, prev, tso);
}
}
#endif
diff --git a/rts/IOManager.h b/rts/IOManager.h
index c8c09440a9..bd7ce35ff7 100644
--- a/rts/IOManager.h
+++ b/rts/IOManager.h
@@ -128,7 +128,7 @@ void markCapabilityIOManager(evac_fn evac, void *user, CapIOManager *iomgr);
* This is used by the select() and the Windows MIO non-threaded I/O manager
* implementation.
*/
-void appendToIOBlockedQueue(StgTSO *tso);
+void appendToIOBlockedQueue(Capability *cap, StgTSO *tso);
/* Insert a thread into the queue of threads blocked on timers.
*
@@ -137,7 +137,7 @@ void appendToIOBlockedQueue(StgTSO *tso);
* The sleeping queue is defined for other non-threaded I/O managers but not
* used. This is a wart that should be excised.
*/
-void insertIntoSleepingQueue(StgTSO *tso, LowResTime target);
+void insertIntoSleepingQueue(Capability *cap, StgTSO *tso, LowResTime target);
#endif
/* Check to see if there are any pending timeouts or I/O operations
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index 537050857d..c20b4d471f 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -2582,7 +2582,7 @@ stg_waitReadzh ( W_ fd )
StgTSO_block_info(CurrentTSO) = fd;
// No locking - we're not going to use this interface in the
// threaded RTS anyway.
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_noregs();
#endif
}
@@ -2598,7 +2598,7 @@ stg_waitWritezh ( W_ fd )
StgTSO_block_info(CurrentTSO) = fd;
// No locking - we're not going to use this interface in the
// threaded RTS anyway.
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_noregs();
#endif
}
@@ -2635,7 +2635,7 @@ stg_delayzh ( W_ us_delay )
* delayed thread on the blocked_queue.
*/
StgTSO_why_blocked(CurrentTSO) = BlockedOnDoProc::I16;
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_async_void();
#else
@@ -2644,7 +2644,7 @@ stg_delayzh ( W_ us_delay )
StgTSO_block_info(CurrentTSO) = target;
- ccall insertIntoSleepingQueue(CurrentTSO "ptr", target);
+ ccall insertIntoSleepingQueue(MyCapability() "ptr", CurrentTSO "ptr", target);
jump stg_block_noregs();
#endif
#endif /* !THREADED_RTS */
@@ -2672,7 +2672,7 @@ stg_asyncReadzh ( W_ fd, W_ is_sock, W_ len, W_ buf )
StgAsyncIOResult_len(ares) = 0;
StgAsyncIOResult_errCode(ares) = 0;
StgTSO_block_info(CurrentTSO) = ares;
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_async();
#endif
}
@@ -2697,7 +2697,7 @@ stg_asyncWritezh ( W_ fd, W_ is_sock, W_ len, W_ buf )
StgAsyncIOResult_len(ares) = 0;
StgAsyncIOResult_errCode(ares) = 0;
StgTSO_block_info(CurrentTSO) = ares;
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_async();
#endif
}
@@ -2722,7 +2722,7 @@ stg_asyncDoProczh ( W_ proc, W_ param )
StgAsyncIOResult_len(ares) = 0;
StgAsyncIOResult_errCode(ares) = 0;
StgTSO_block_info(CurrentTSO) = ares;
- ccall appendToIOBlockedQueue(CurrentTSO "ptr");
+ ccall appendToIOBlockedQueue(MyCapability() "ptr", CurrentTSO "ptr");
jump stg_block_async();
#endif
}