FFI, safe vs unsafe

John Meacham john at repetae.net
Thu Mar 30 07:30:27 EST 2006


On Thu, Mar 30, 2006 at 01:16:08PM +0100, Claus Reinke wrote:
> >It is not like inserting yields needs to be done much at all since we have
> >progress guarentees, so we know the program is doing something and on
> >any blocking call that could potentially take a while, the library will
> >yield for you.
> 
> where do we get the progress guarantees from? do we need a 
> "yield-analysis"? something that will automatically insert yields
> in the code after every n atomic steps, and complain if it cannot 
> infer that some piece of code is atomic, but cannot insert a yield 
> either? how much of the burden do you want to shift from the
> implementer to the programmer?

no, because there are only certain defined actions that can switch a
thread's state from 'runnable' to 'not-runnable'. In order to
meet the progress guarentee you just need to make sure that when the
current thread switches from 'runnable' to 'not-runnable' that another
thread is chosen.

examples of these points would be:

 - calling a foreign concurrent import
 - waiting for input on a handle
 - waiting for a UNIX signal
 - changing thread priorities (possibly)

in any case, the compiler need do nothing special in general, it is
basically a library issue.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-prime mailing list