Session 11 : High Level Linguistic Constructs
High Level Lingustic Synchronization Constructs
~*~
T H O U G H T P R O V O K I N G ~*~ "If Exposure Of Body Is
...Modernization, Then Animal Are More Modern Than Humans …"
Q?What are critical regions
/>they are the high level synchronization constructs
/>a shared variable v of type T, is declared as shared T v;
/>this variable v can be accessed only inside statement
region v do S
So while statement S is being executed, no other process can access
variable v.
/>this variable can be used by a single
process at a time.
Q?What are nested critical regions
/>
shared
V v;
shared
W w;
region
v
do
begin
....
region
w do
.... ;
...
end
Q?What is the inner construct of this shared and region keyword
/>
Q?What are the problems with nested critical region
/>two or more process wait indefinitely for the event to occur that is
mainly caused due to one blocked event
/>deadlock occurs here
Q?How to solve producer-consumer problem with critical regions
/> typedef struct BUFFER_tag {
shared
Message
buffer[MAX];
shared
int
p = 0, c=0;
semaphore_t
full=0, empty= MAX;
}BUFFER;
//producer
send(Message
m, Buffer b){
WAIT(b.empty){
region
b.p
do{
buffer[b.p]=
m;
b.p
= (b.p +1) % MAX;
}
SIGNAL(b.full);
}
}
//consumer
receive(Message
m, Buffer b){
WAIT(b.full);
region
b.c
do{
m
= buffer[b.c];
b.c
= (b.c+1) %MAX;
}
SIGNAL(b.empty);
}
Q?What are Conditional Critical Regions : CCR's
/>
region v when B do S ;
/>when a process tries to execute the region statement the Boolean
expression B is evaluated
if B is true, the statement B is evaluated
else the process is delayed(waits) until B becomes true and no other
process is in the region associated with v
Q?How to solve producer-consumer problem using CCR's
/>
Q?when we use this await conditon
/>
region v do S1 await B do S2;
/>It is used when a process can execute S1 – in mutual
exclusion – before testing
the boolean expression B and possibly be blocked.
Q>Show the implementation of statement ”region v do when B do S “
/>For every variable v declared & shared the compiler produces a
structure with the following fields:
v: the value of v
mutex: semaphore of mutual exclusion that protect variable v
delay: semaphore that blocks the processes whose condition B is false
count: number of processes blocked on semaphore delay
temp: counter of the number of processes in the list of semaphore delay
that have already tested their conditions after a process have leaved
its critical region.
Q?describe Readers & Writers problems
/>There is a class of process called Readers that can access
a database in parallel. Whereas , there is also a class of
process called Writers that must access
a database in mutual exclusion with other Writers and Reader
processes. During the access of a Writer to the database, several
Readers and Writers processes can be blocked outside their CCRs.
Managing this readers and writer processes avoiding
the deadlock is called Readers & Writers Problem.
So we can solve this problem by either giving precedence to the Reader
or the precedence to the writer.
Q?How is the Readers Precedence solution implemented in Readers &
Writers problem
/>Several Reader and Writer processes can be blocked outside their CCRs
waiting.
In this situation to give precedence to the Readers means favour
the access of the waiting Readers rather than the waiting
Writers.
Q?How is the Writers Precedence solution implemented in Readers &
Writers problem
/>Several Reader and Writer processes can be blocked outside their CCRs
waiting.
In
this situation to give precedence to the Writers means favour the
access of the waiting Writers rather than the waiting Readers.
Comments
Post a Comment