home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
cs.rhul.ac.uk
/
www.cs.rhul.ac.uk.zip
/
www.cs.rhul.ac.uk
/
pub
/
CS375
/
attempt3.pc
< prev
next >
Wrap
Text File
|
1999-02-05
|
632b
|
44 lines
program attempt3;
var
turn: integer;
shared: integer;
process P1;
var
loop: integer;
begin
for loop := 1 to 20 do
begin
while turn = 2 do
null;
(* enter critical section *)
shared := shared + 1;
(* leave critical section *)
turn := 2
end
end; (* P1 *)
process P2;
var
loop: integer;
begin
for loop := 1 to 20 do
begin
while turn = 1 do
null;
(* enter critical section *)
shared := shared + 1;
(* leave critical section *)
turn := 1
end
end; (* P2 *)
begin
turn := 1;
shared := 0;
cobegin
P1;
P2
coend;
writeln(shared)
end.