Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 19 Sep 2010 00:29:05 +0000 (00:29 +0000)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 19 Sep 2010 00:29:05 +0000 (00:29 +0000)
commit83d563cb9ede0ba792836e529b1e2929db926355
tree1f9de77ebd24ca7a67894c51442b657d2f265630
parent9fa96fc44a640014415e1588f50ab7689285e6cb
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.
32 files changed:
compiler/cmm/Cmm.hs
compiler/cmm/CmmBuildInfoTables.hs
compiler/cmm/CmmCPSGen.hs
compiler/cmm/CmmParse.y
compiler/cmm/CmmStackLayout.hs
compiler/cmm/MkZipCfgCmm.hs
compiler/cmm/PprCmm.hs
compiler/cmm/ZipCfgCmmRep.hs
compiler/codeGen/CgForeignCall.hs
compiler/codeGen/StgCmmForeign.hs
compiler/deSugar/DsMeta.hs
compiler/ghci/ByteCodeAsm.lhs
compiler/ghci/ByteCodeGen.lhs
compiler/ghci/ByteCodeInstr.lhs
compiler/hsSyn/Convert.lhs
compiler/hsSyn/HsDecls.lhs
compiler/parser/Lexer.x
compiler/parser/Parser.y.pp
compiler/prelude/ForeignCall.lhs
docs/users_guide/ffi-chap.xml
includes/rts/Constants.h
includes/rts/OSThreads.h
includes/rts/Threads.h
rts/Interpreter.c
rts/RaiseAsync.c
rts/Schedule.c
rts/Task.c
rts/Task.h
rts/Threads.c
rts/posix/OSThreads.c
rts/sm/MarkWeak.c
rts/win32/OSThreads.c