[Yhc] Re: some initial questions
Malcolm.Wallace at cs.york.ac.uk
Wed Mar 8 05:11:18 EST 2006
Simon Marlow <simonmar at gmail.com> wrote:
> I think it's fantastic that you guys have got concurrency working,
Me too. Well done chaps.
> Can you really context switch between two arbitrary instructions? Is
> the stack in a GC'able state at all times?
AFAIK, the context switch can only happen at "safe" moments, namely at a
NEEDHEAP (or NEEDSTACK?) instruction. Ordinary heap allocation is
unchecked for overflow, so if there were arbitrary context switches, a
thread could check there is enough space available with a NEEDHEAP, be
switched out, then resume when the heap has been exhausted by another
thread: crash bang. Thus, the atomic unit of thread work must be
exactly the sequence of instructions bounded by NEEDHEAP checks.
> What happens if the FFI call invokes a callback? (a foreign export,
> or foreign import wrapper)? Can callbacks be invoked by multiple OS
> threads? Are you planning to implement bound threads?
At the moment, I'm pretty sure yhc does not implement foreign import
wrapper. (That one is on my todo list for nhc98 as well.) But the
point stands, even with foreign export. Does the exported Haskell
function get run in the separate OS thread (causes heap-locking issues)?
Or will it be added back into the internal thread pool?
More information about the Yhc