On 06/08/2010 21:16, Edward Z. Yang wrote:
Excerpts from Corey O'Connor's message of Fri Aug 06 16:15:21 -0400 2010:
In your test cases that fail are your C computations foreign unsafe imports?

First thing I checked. :-) They were safe imports, and the Haskell code
did get called--just the C code kept marching on.

Right, the RTS won't try to interrupt a foreign call even when there's a pending throwTo for the thread making the call. The reason is that, well, there's no way to interrupt C calls. You could try pthread_cancel I suppose, but only if the thread making the call is not a bound thread (because pthread_cancel kills the thread, it's not an exception mechanism). That might be quite interesting to try, actually. You'll need to modify the RTS: the place where we decide what to do when a throwTo is received for a thread involved in a foreign call is around line 396 of rts/RaiseAsync.c (in the HEAD):

    case BlockedOnCCall:
    case BlockedOnCCall_NoUnblockExc:
        blockedThrowTo(cap,target,msg);
        return THROWTO_BLOCKED;

this is where you would call pthread_cancel (after checking for a bound thread). You should look into pthread_setcancelstate and pthread_setcanceltype, and call these appropriately for worker threads.

Cheers,
        Simon
_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to