anhtao test and set
program test and set
var
disable1,disable2:boonlean;
active:boolean;
procedure process1
var
disable1:boonlean;
begin
while true do begin
....
disable1:=true;
while disable1=true do
test and set(disable1,active);
{critical region}
Active:=false;
.......
End;
End;
Procedure process2
Var
Disable2;boonlean;
Begin
While true do begin
.........
Disable2:=true;
While disable2=true;
Test and set(disable2,active);
{ critical region }
Active:=false;
.......
End;
End;
Begin
Active:=false;
Parbegin
Process1;
Process2;
Par end;
End;
Bạn đang đọc truyện trên: Truyen247.Pro