Re: FFI "wrapper"

Malcolm Wallace <[email protected]> Thu, 16 Oct 2008 16:08:19 +0100
Newsgroups gmane.comp.lang.haskell.nhc.user
Organization Dept of Computer Science, University of York
Message-ID <[email protected]>
Donn,

> a thread
> interlock that serializes access from different threads to the
> runtime, The thread that holds the lock runs until an I/O operation,
> then releases the lock,

Provided we are talking about a single sequential processor, then
concurrent thread access to the heap should be largely OK I guess,
because heap values are immutable.  The only thing the RTS needs to be
careful about is if one thread accesses a heap cell and finds it is
blackholed (i.e. currently under evaluation by a different thread), then
it should block until the cell is updated.  I believe Yhc already does
this.

However, if there are multiple processors accessing the same shared
memory containing the heap, then I suppose the RTS would additionally
need to place a lock around an individual cell during the heap-update
operation.  The GC would also need to stop all threads whilst collecting.

Regards,
    Malcolm