home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cs.rhul.ac.uk
/
www.cs.rhul.ac.uk.zip
/
www.cs.rhul.ac.uk
/
pub
/
CS375
/
gardens2.pfc
< prev
next >
Wrap
Text File
|
1999-03-15
|
602b
|
48 lines
program gardens2;
(*
semaphore solution to Ornamental
Gardens problem
*)
var
count: integer;
mutex: semaphore;
process turnstile1;
var
loop: integer;
begin
for loop := 1 to 20 do
begin
wait(mutex);
count := count + 1;
signal(mutex)
end
end; (* turnstile1 *)
process turnstile2;
var
loop: integer;
begin
for loop := 1 to 20 do
begin
wait(mutex);
count := count + 1;
signal(mutex)
end
end; (* turnstile2 *)
begin
count := 0;
initial(mutex,1);
cobegin
turnstile1;
turnstile2
coend;
writeln('Total admitted: ',count)
end.