summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2010-09-19 00:29:05 +0000
committerEdward Z. Yang <ezyang@mit.edu>2010-09-19 00:29:05 +0000
commit83d563cb9ede0ba792836e529b1e2929db926355 (patch)
tree1f9de77ebd24ca7a67894c51442b657d2f265630 /includes
parent9fa96fc44a640014415e1588f50ab7689285e6cb (diff)
downloadhaskell-83d563cb9ede0ba792836e529b1e2929db926355.tar.gz
Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4
This is patch that adds support for interruptible FFI calls in the form of a new foreign import keyword 'interruptible', which can be used instead of 'safe' or 'unsafe'. Interruptible FFI calls act like safe FFI calls, except that the worker thread they run on may be interrupted. Internally, it replaces BlockedOnCCall_NoUnblockEx with BlockedOnCCall_Interruptible, and changes the behavior of the RTS to not modify the TSO_ flags on the event of an FFI call from a thread that was interruptible. It also modifies the bytecode format for foreign call, adding an extra Word16 to indicate interruptibility. The semantics of interruption vary from platform to platform, but the intent is that any blocking system calls are aborted with an error code. This is most useful for making function calls to system library functions that support interrupting. There is no support for pre-Vista Windows. There is a partner testsuite patch which adds several tests for this functionality.
Diffstat (limited to 'includes')
-rw-r--r--includes/rts/Constants.h4
-rw-r--r--includes/rts/OSThreads.h1
-rw-r--r--includes/rts/Threads.h2
3 files changed, 4 insertions, 3 deletions
diff --git a/includes/rts/Constants.h b/includes/rts/Constants.h
index 354abbbdd9..140aaa4210 100644
--- a/includes/rts/Constants.h
+++ b/includes/rts/Constants.h
@@ -223,8 +223,8 @@
#define BlockedOnGA_NoSend 9
/* Only relevant for THREADED_RTS: */
#define BlockedOnCCall 10
-#define BlockedOnCCall_NoUnblockExc 11
- /* same as above but don't unblock async exceptions in resumeThread() */
+#define BlockedOnCCall_Interruptible 11
+ /* same as above but permit killing the worker thread */
/* Involved in a message sent to tso->msg_cap */
#define BlockedOnMsgThrowTo 12
diff --git a/includes/rts/OSThreads.h b/includes/rts/OSThreads.h
index 106e1e7e9f..5d3e6ba140 100644
--- a/includes/rts/OSThreads.h
+++ b/includes/rts/OSThreads.h
@@ -165,6 +165,7 @@ typedef void OSThreadProcAttr OSThreadProc(void *);
extern int createOSThread ( OSThreadId* tid,
OSThreadProc *startProc, void *param);
extern rtsBool osThreadIsAlive ( OSThreadId id );
+extern void interruptOSThread (OSThreadId id);
//
// Condition Variables
diff --git a/includes/rts/Threads.h b/includes/rts/Threads.h
index ca3e8b2da0..c974142ce3 100644
--- a/includes/rts/Threads.h
+++ b/includes/rts/Threads.h
@@ -31,7 +31,7 @@ StgTSO *createStrictIOThread (Capability *cap, nat stack_size,
StgClosure *closure);
// Suspending/resuming threads around foreign calls
-void * suspendThread (StgRegTable *);
+void * suspendThread (StgRegTable *, rtsBool interruptible);
StgRegTable * resumeThread (void *);
//