can you block a thread in GHC by its threadID?
Bernard James POPE
bjpop at cs.mu.OZ.AU
Tue Jun 22 01:11:05 EDT 2004
Ideally I'd like this function:
blockThread :: ThreadId -> IO ()
unBlockThread :: ThreadId -> IO ()
However I can see that there might be some tricky issues to resolve,
such as what happens if you try to block an already blocked thread?
Perhaps the return type could indicate whether the request to block
succeeded, or if not why it failed.
I'm not very familiar with Concurrent Haskell, so if you can see any
pitfalls please point them out.
Why do I want this?
Again this is for my Haskell debugger. Basically I want the
debuggee to run in its own thread. The user of the debugger
should be able to request that the debuggee be suspended,
do some debugging, and perhaps later resume the execution of
the debuggee. If it helps for simplicity, assume that the
debuggee doesn't fork its own threads --- although of course
we'd have to support that situation also, eventually.
Thus I want the debugger to act as a controlling thread that
can influence the scheduling of the debuggee without the
debuggee knowing anything about it.
An alternative solution is to have the debuggee poll an MVar
periodically, but I think this has obvious drawbacks.
More information about the Glasgow-haskell-users