[mercury-users] Native garbage collector for Mercury

Peter Schachte pets at cs.mu.OZ.AU
Mon Sep 14 15:14:55 AEST 1998


On Mon, Sep 14, 1998 at 12:48:34PM +1000, Thomas Charles CONWAY wrote:
> Peter Schachte, you write:

> > But how do you steal the io__state from the predicate that's running
> > when the interrupt happens, and put it back when the interrupt closure
> > completes?
> 
> I'm not sure I quite understand the problem. Remember that the io__state
> thing that you pass around is really only a `token' that enforces
> sequentiality.

But in this case you don't want sequentiality.  Or, looked at
differently, you just can't express what you want logically.  Let's
say you have a character count predicate

	count(Buffer, Len0, Len, IO0, IO) :-
		(   is_empty(Buffer, IO0) ->
			IO = IO0,
			Len = Len0
		;   next_char(Buffer, _Char, IO0, IO1),
		    count(Buffer, Len0+1, Len, IO1, IO)
		).

Remember, the buffer is being written concurrently (maybe it's a
pipe).  Suppose that is_empty/2 and next_char/4 are implemented to
look in the io__state and do the appropriate thing if the buffer has
characters in it or if it's empty and has been closed.  If someone is
still writing to it but we've emptied the buffer, then we suspend.

So how do we write a call to count/5 that says that the buffer is to
be filled by a different process?  And how to we write the interrupt
handler (in Mercury, no destructive C hacks please) to modify the
io__state that count/5 is using, possibly waking count/5 if it's
suspended waiting for input?


-- 
Peter Schachte                | Apologists for Economic Darwinism seem to
mailto:pets at cs.mu.OZ.AU       | forget that the goal is maximum aggregate
http://www.cs.mu.oz.au/~pets/ | utility -- not just having the fittest
PGP: finger pets at 128.250.37.3 | corporations. -- me 



More information about the users mailing list