diff options
author | Duncan Coutts <duncan@well-typed.com> | 2021-01-03 18:37:51 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-25 05:11:14 -0500 |
commit | e3564e3893c90dc20aa1949cdb85f41741faf895 (patch) | |
tree | f7988daba467d3b84923e392326ad7607896148c /rts | |
parent | 9a7d19ba0a3a3e2f9a0ffa270895d09c912240f0 (diff) | |
download | haskell-e3564e3893c90dc20aa1949cdb85f41741faf895.tar.gz |
Add a common wakeupIOManager hook
Use in the scheduler in threaded mode.
Replaces the direct call to ioManagerWakeup which are part of specific
I/O manager implementations.
Diffstat (limited to 'rts')
-rw-r--r-- | rts/IOManager.c | 14 | ||||
-rw-r--r-- | rts/IOManager.h | 18 | ||||
-rw-r--r-- | rts/Schedule.c | 2 |
3 files changed, 33 insertions, 1 deletions
diff --git a/rts/IOManager.c b/rts/IOManager.c index 2e178435cb..da1d71dd15 100644 --- a/rts/IOManager.c +++ b/rts/IOManager.c @@ -116,6 +116,20 @@ exitIOManager(bool wait_threads USED_IF_NOT_THREADS_AND_MINGW32) } +/* Wakeup hook: called from the scheduler's wakeUpRts (currently only in + * threaded mode). + */ +void wakeupIOManager(void) +{ +#if defined(THREADED_RTS) + /* Posix implementation in posix/Signals.c + * Win32 implementation in win32/ThrIOManager.c + */ + ioManagerWakeup(); +#endif +} + + /* Declared in rts/IOInterface.h. Used only by the MIO threaded I/O manager on * Unix platforms. */ diff --git a/rts/IOManager.h b/rts/IOManager.h index 1059f4212e..614c3ac9c7 100644 --- a/rts/IOManager.h +++ b/rts/IOManager.h @@ -48,6 +48,24 @@ void initIOManagerAfterFork(/* inout */ Capability **pcap); void stopIOManager(void); void exitIOManager(bool wait_threads); + +/* Wakeup hook: called from the scheduler's wakeUpRts (currently only in + * threaded mode). + * + * The I/O manager can be blocked waiting on I/O or timers. Sometimes there are + * other external events where we need to wake up the I/O manager and return + * to the schedulr. + * + * At the moment, all the non-threaded I/O managers will do this automagically + * since a signal will interrupt any waiting system calls, so at the moment + * the implementation for the non-threaded I/O managers does nothing. + * + * For the I/O managers in threaded mode, this arranges to unblock the I/O + * manager if it waa blocked waiting. + */ +void wakeupIOManager(void); + + /* * Communicating with the IO manager thread (see GHC.Conc). * Posix implementation in posix/Signals.c diff --git a/rts/Schedule.c b/rts/Schedule.c index 0ee8f70cfe..390e505cf2 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -2893,7 +2893,7 @@ void wakeUpRts(void) // This forces the IO Manager thread to wakeup, which will // in turn ensure that some OS thread wakes up and runs the // scheduler loop, which will cause a GC and deadlock check. - ioManagerWakeup(); + wakeupIOManager(); } #endif |