Hardware Solution - Test and Set
Test and modify the content of a word atomically.
Function Test-and-Set( var target: boolean ) : boolean
begin
Test-and-Set := target;
target := true;
end
Other variants exist.
Shared lock: boolean =false;
Repeat
while Test-and-Set(lock)
do no-op;
critical section
lock := false;
remainder section
Forever
Previous slide
Next slide
Back to first slide
View graphic version