Way to expose BLACKHOLES through an API?

Duncan Coutts duncan.coutts at googlemail.com
Wed Nov 16 10:43:27 CET 2011


On Tue, 2011-11-08 at 15:43 +0000, Simon Marlow wrote:

> Hmm, but there is something you could do.  Suppose a thread could be in 
> a mode in which instead of blocking on a BLACKHOLE it would just throw 
> an asynchronous exception WouldBlock.  Any computation in progress would 
> be safely abandoned via the usual asynchronous exception mechanism, and 
> you could catch the exception to implement your evaluateNonBlocking 
> operation.
> 
> I'm not sure this would actually be useful in practice, but it's 
> certainly doable.

The linux kernel folks have been discussing a similar idea on and off
for the last few years. The idea is to "return" in another thread if the
initial system call blocks.

Perhaps there's an equivalent here. We have an evaluateThingy function
and when the scheduler notices that thread is going to block for some
reason (either any reason or some specific reason) we return from
evaluateThingy with some info about the blocked thread.

The thing that the kernel folks could never decide on was to do with
thread identity: if it was the original thread that blocked and we
return in a new thread, or if the original thread returns and a clone is
the one that blocks.

Or perhaps it's a crazy idea and it would never work at all :-)

Duncan




More information about the Glasgow-haskell-users mailing list