(* * Producer/Consumer Test Module * * This module tests the WAIT and SEND functions * found in the Processes module and is adapted * from code found on page 346 of Advanced Modula-2 * by Herber Schildt available from McGraw-Hill. * * Corrected version - David Granz, 14-Mar-87 * *) MODULE ProCon; FROM Terminal IMPORT WriteLn,WriteString; FROM SYSTEM IMPORT WORD,PROCESS,ADR,NEWPROCESS,TRANSFER; FROM Processes IMPORT WAIT,SEND,StartProcess,Init,SIGNAL; CONST EOL = 36C; EOT = 32C; VAR buf: ARRAY[0..100] OF CHAR; S: SIGNAL; PROCEDURE Consumer; BEGIN LOOP WriteString("waiting"); WriteLn; WAIT(S); WriteString("consumed:"); WriteString(buf); WriteLn; END; END Consumer; PROCEDURE Producer; VAR count: CARDINAL; ch: CHAR; BEGIN count := 0; LOOP READ(ch); (* Clear character buffer *) IF (ch <> EOL) AND (count < 99) THEN buf[count] := ch; INC(count); ELSE buf[count] := CHR(0); (* Null terminator *) SEND(S); count := 0; END; END; END Producer; BEGIN Init(S); StartProcess(Consumer,1000); Producer; END ProCon. S............1-364-2474...2400 N81N Procomm BBS........