[Haskell-cafe] Re: FFI and callbacks
jgoerzen at complete.org
Mon Jul 25 09:47:50 EDT 2005
On 2005-07-25, Simon Marlow <simonmar at microsoft.com> wrote:
> On 23 July 2005 03:38, Duncan Coutts wrote:
> Thanks for describing the problem in detail, I understand it better now.
> I think it comes down to this conflict:
> - you want to take advantage of the fact that GHC has lightweight
> "green" threads in order to do multithreading within a single OS
> thread, but
> - our "bound threads" design does not require the implementation
> to support lightweight threads, and hence doesn't let the
> programmer take advantage of them.
In my particular case, the C library isn't aware of threading at all.
While it may be safe to call it from any arbitrary Haskell thread, it
would not be safe to call it from two threads simultaneously.
It seems that some sort of global lock -- implemented as a global
variable of some sort, I guess -- is necessary. I'm not sure exactly
how to accomodate that.
It seems the current model doesn't work all that well in this scenario,
unless I'm missing something?
More information about the Haskell-Cafe