[Haskell-cafe] Re: errno handling in concurrent haskell
manlio_perillo at libero.it
Tue Jan 13 09:28:28 EST 2009
Simon Marlow ha scritto:
> Manlio Perillo wrote:
>> I have some doubts about errno handling in a Concurrent Haskell program.
>> Let's suppose that GHC non threaded runtime is used, so that each
>> Haskell thread is bound to an OS thread.
>> Let's suppose there are two threads running (`A` and `B`).
>> Thread `A` calls a function `f`, that, in turn, calls via FFI a C
>> function `c_f`.
>> Function `c_f` fails, settings errno; however the GHC scheduler
>> suspends execution of thread `A` and switch to thread `B`, before the
>> current value of errno is read.
>> Now, let's suppose thread `B` calls a function `g`, that, in turn,
>> calls via FFI a C function `c_g`.
>> Function `c_g`, too, fails, setting errno.
>> Is this possible?
> It's safe, we save the value of errno when a Haskell thread is
> descheduled, and restore it when it is scheduled again. We do the same
> on Windows for GetLastError().
I was just replying to the message, after having read the code of the
More information about the Haskell-Cafe