FFI, signals and exceptions

Edward Z. Yang ezyang at MIT.EDU
Thu Aug 26 13:20:31 EDT 2010


Ahem, the logic in that last iteration was not quite correct.
Here is the more correct version:

    case BlockedOnCCall:
    case BlockedOnCCall_NoUnblockExc:
    {
#ifdef THREADED_RTS
        Task *task = NULL;
        if (!target->bound) {
            // walk all_tasks to find the correct worker thread
            for (task = all_tasks; task != NULL; task = task->all_link) {
                if (task->incall->suspended_tso == target) {
                    break;
                }
            }
            if (task != NULL) {
                raiseAsync(cap, target, msg->exception, rtsFalse, NULL);
                pthread_cancel(task->id);
                task->cap = NULL;
                task->stopped = rtsTrue;
                return THROWTO_SUCCESS;
            }
        }
#endif
        blockedThrowTo(cap,target,msg);
        return THROWTO_BLOCKED;
    }

Is a lock necessary to walk all_tasks?

Cheers,
Edward


More information about the Glasgow-haskell-users mailing list