can you block a thread in GHC by its threadID?

Hi again, Ideally I'd like this function: blockThread :: ThreadId -> IO () and thus: 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. Cheers, Bernie.

In local.glasgow-haskell-users, you wrote:
Ideally I'd like this function: blockThread :: ThreadId -> IO () unBlockThread :: ThreadId -> IO ()
I should have some bit-rotted patches here for freezeThread :: ThreadId -> IO () thawThread :: ThreadId -> IO () and a new PrimOp which allows you to set the next thread to run (at a first glance, at least I could find the patch for the latter). Volker -- http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME Neu! Ändern Sie den Anfangstag Ihrer Woche

On Tue, Jun 22, 2004 at 10:37:54AM +0200, Volker Stolz wrote:
In local.glasgow-haskell-users, you wrote:
Ideally I'd like this function: blockThread :: ThreadId -> IO () unBlockThread :: ThreadId -> IO ()
I should have some bit-rotted patches here for freezeThread :: ThreadId -> IO () thawThread :: ThreadId -> IO () and a new PrimOp which allows you to set the next thread to run (at a first glance, at least I could find the patch for the latter).
If you could find them that would be great. Cheers, Bernie.
participants (2)
-
Bernard James POPE
-
Volker Stolz