Newsgroups: comp.sys.transputer,comp.lang.misc
From: andyr@wizzy.com (Andy Rabagliati)
Subject: Re: ALTs and PRI ALTs,  TRUEs & SKIPs
Organization: W.Z.I.
Date: Mon, 2 May 1994 19:42:32 GMT
Message-ID: <Cp6xEw.DCE@wizzy.com>

In article <JAN.94May2181021@thalia.neuroinformatik.ruhr-uni-bochum.de>,
Jan Vorbrueggen <jan@neuroinformatik.ruhr-uni-bochum.de> wrote:
>In article <Cp0Co5.E37@wizzy.com> andyr@wizzy.com (Andy Rabagliati) writes:
>
>   That said, there are a few (very few) places where TRUE & SKIP can be
>   useful. One example is :-
>
>	   Continue calculating prime numbers until I press a key.
>
>   This requires PRI ALT with TRUE & SKIP.
>


>Another example is a 'leaky' buffer. The one I needed was an interrupt
>service routine (connected to a camera's VSYNC) that, among other
>things like triggering a frame grabber's ADC, notified a readout
>process that data was ready. Potentially, and very much so during
>development of the code, the interrupt service routine could hang if
>the readout process was still occupied with the previous frame. In this
>case TRUE & SKIP (of course with PRI ALT!) was very useful.

What,  no mention of CHALLENGE in the subject ? :-)

This is a non-busy leaky buffer,  with a storage depth of 2.
Nary a SKIP to be seen,  very useful in real applications.

Cheers,       Andy.



PROC leaky.buffer (CHAN OF INT in, out)
  CHAN OF BOOL ack :
  CHAN OF INT pass :
  PAR
    BOOL ready :
    INT baby :
    SEQ
      ready := FALSE
      WHILE TRUE
        ALT
	  in ? baby        -- toss out old one if ready was already true
	    ready := TRUE
	  ready & ack ? ready
	    pass ! baby
    WHILE TRUE
      INT baby :
      SEQ
        ack ! FALSE
	pass ? baby
	out ! baby
:

