[GHC] #9519: Add a way to mask thread preemption via fired timer for a computation
GHC
ghc-devs at haskell.org
Thu Aug 28 08:41:53 UTC 2014
#9519: Add a way to mask thread preemption via fired timer for a computation
-------------------------------------+-------------------------------------
Reporter: abbradar | Owner: simonmar
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version: 7.8.2
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
This follows haskell-cafe discussion [http://www.haskell.org/pipermail
/haskell-cafe/2014-August/115656.html]. In brief: some C libraries (for
example, SDL) use thread-local variables for error state of the last call.
Without some way to temporarily mask timer-based lightweight thread
preemption on one OS thread, there is no safe way to use such libraries
and retrieve errors aside from using a global MVar (which will block all
calls, not just ones on the same OS thread). For "errno" variable from C
standard library, this is handled explicitly in RTS by saving its state
for each lightweight thread.
So the proposal is: add new prims (something in lines of
"maskPreemption#", "unmaskPreemption#" and "getPreemptionState#") which
will make a computation not preemptable via fired timer and temporarily
attached to one OS thread, and corresponding functions in
Control.Concurrent. They should be able to be used together with
"Control.Exception.mask" to also block async exceptions, if this is
needed.
(I'm sorry if I've misunderstood something or did something the wrong way;
I don't know the internal workings of RTS and this is my first GHC bug
report).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9519>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list