home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol162 / bounded.ccp < prev    next >
Encoding:
Text File  |  1984-04-29  |  463 b   |  34 lines

  1. program demo;
  2.  
  3. var notfull,notempty: semaphore;
  4.     x : integer;
  5.  
  6.  
  7. procedure process1;
  8. begin
  9.   while true do
  10.   begin
  11.      wait(notfull);
  12.      writeln('process 1');
  13.      readln(x);
  14.      signal(notempty);
  15.   end;
  16. end;
  17.  
  18. procedure process2;
  19. begin
  20.   while true do
  21.   begin
  22.      wait(notempty);
  23.      writeln('process 2');
  24.      writeln(x);
  25.      signal(notfull);
  26.   end;
  27. end;
  28.  
  29. begin
  30.   writeln('start');
  31.   notfull := 1; notempty := 0;
  32.   cobegin process1;process2 coend;
  33. end.
  34.