views:

34

answers:

0
Program Parcial2;
type buffer = channel of integer;
var buffers : array [1..2] of buffer;
  val:integer;

process sleeper (id:integer);
var i : integer;
begin 
   for i:=1 to 10 do
   begin
     sleep (random(10*id));
     **buffers (id):any;**
   end;
end;

process troll;
begin
  buffers[1]: random(10);
end;



process watcher;
   begin 
     repeat
       select
         buffers[1] ? val;
       or
         buffers[2] ? val;
       or
         terminate
       end;
       print (val);
     forever;
end;
var sleepers : array [1..2] of sleeper;
begin
  cobegin
    sleepers [1](1); sleepers [2](2);
    troll; watcher;
  coend
end.

What are buffers(id):any , buffers[1]:random(10) and sleepers [1](1); sleepers [2](2); doing?