Newsgroups: comp.sys.transputer From: andyr@wizzy.com (Andy Rabagliati) Subject: Re: The "buffer-copying problem" in OCCAM and CSP Organization: W.Z.I. Date: Thu, 7 Apr 1994 23:33:49 GMT I regularly use the procedure listed below. It can build a deep fifo very efficiently. The principle can be carried further. Share a big buffer between two parallel processes, #PRAGMA SHARE the buffer, and then just input and output indices into this buffer. It maintains all the properties of fine parallel programming, when used correctly, without the copying overhead that concerns you. Cheers, Andy. Andy Rabagliati . andyr@wizzy.com . W.Z.I. Consulting . (719)635-6099 PROC buff ( CHAN OF my.protocol in, out) VAL INT size.buffer IS 99 : -- This whole thing is just a more efficient way of doing -- a size.buffer deep FIFO of this protocol. It behaves identically. -- andyr@wizzy.com (Andy Rabagliati) CHAN OF BOOL ack : CHAN OF my.protocol pass : PAR --{{{ input process and storage [size.buffer][block.size]BYTE buffer : INT input, output : -- head and tail of FIFO #PRAGMA PERMITALIASES input SEQ input, output := 0, 0 WHILE TRUE BOOL any : VAL INT next IS ((input + 1) REM size.buffer) : ALT input <> output & ack ? any -- don't over-empty SEQ pass ! buffer[output] output := (output+1) REM size.buffer next <> output & in ? buffer[input] -- don't over-fill input := next --}}} --{{{ output process [block.size]BYTE packet : WHILE TRUE SEQ ack ! TRUE pass ? packet out ! packet --}}} :