A critical region is a section of code that is always executed under mutual exclusion. Critical regions shift the responsibility for enforcing mutual exclusion from the programmer(where it resides when semaphores are used) to the compiler.
They consist of two parts:
- Variables that must be accessed under mutual exclusion.
- A new language statement that identifies a critical region in which the variables
are accessed.
var
v : shared T;
...
region v do
begin
...
end;
All critical regions that are ‘tagged’ with the same variable have compiler-enforced mutual exclusion so that only one of them can be executed at a time:
Process A:
region V1 do
begin
{Do some stuff.}
end;
region V2 do
begin
{Do more stuff.}
end;
Process B:
region V1 do
begin
{Do other stuff.}
end;
Here process A can be executing inside its V2 region while process Bis executing inside its V1 region, but if they both want to execute inside their respective V1 regions only one will be permitted to proceed.
Saturday, January 9, 2010
Critical Regions
Posted by Sunflower at 1/09/2010 12:09:00 AM
Labels: Code, Critical Region, Mutual Exclusions, Programing, Semaphores
Subscribe by Email |
|
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment