summaryrefslogtreecommitdiff
path: root/rts/Timer.c
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-05-24 12:28:39 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-05-24 12:28:39 +0000
commit7a1f8fbdbab99465793c50bd9fb376c950e7e9d7 (patch)
tree04e40cc95c37d452ed26ca9909b1ff97abe8aeac /rts/Timer.c
parent3065ea2499deee8d4152eaf0804cc92c7217a2ba (diff)
downloadhaskell-7a1f8fbdbab99465793c50bd9fb376c950e7e9d7.tar.gz
Better control of the IO manager thread; improvements to deadlock checking
In the threaded RTS on *nix platforms: - we now start the IO manager thread eagerly at startup time (previously was started on demand). - we now ask the IO manager thread to stop at shutdown - In Timer.c:handle_tick, if it looks like we might be in a deadlock, instead of calling prodOneCapability() which was known to be wrong, we now send a byte down the IO manager's pipe to wake it up. This also avoids a case of double-acquisition of a mutex, which happened if prodOneCapability() was called while the current thread was holding a mutex.
Diffstat (limited to 'rts/Timer.c')
-rw-r--r--rts/Timer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/rts/Timer.c b/rts/Timer.c
index 0bfea2d6fd..4b13be4556 100644
--- a/rts/Timer.c
+++ b/rts/Timer.c
@@ -21,6 +21,7 @@
#include "Timer.h"
#include "Ticker.h"
#include "Capability.h"
+#include "RtsSignals.h"
/* ticks left before next pre-emptive context switch */
static int ticks_to_ctxt_switch = 0;
@@ -71,12 +72,19 @@ handle_tick(int unused STG_UNUSED)
blackholes_need_checking = rtsTrue;
/* hack: re-use the blackholes_need_checking flag */
+#if !defined(mingw32_HOST_OS)
+ // 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();
+#else
/* ToDo: this doesn't work. Can't invoke
* pthread_cond_signal from a signal handler.
* Furthermore, we can't prod a capability that we
* might be holding. What can we do?
*/
prodOneCapability();
+#endif
}
break;
default: