Process Synchronization in Operating System Gate Questions and topics discussion|part1
Questions on Race Condition and Critical Section
Q1)Consider three concurrent processes P1, P2 and P3 as shown below, which access a shared variable D that has been initialized to 100.
The process are executed on a uniprocessor system running a time-shared operating system. If the minimum and maximum possible values of D after the three processes have completed execution are X and Y respectively, then the value of Y–X is __________.
Q2)The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1() { C = B - 1; B = 2 * C;}P2(){ D = 2 * B; B = D - 1;}
The number of distinct values that B can possibly take after the execution is______________________.
Q3)A critical section is a program segment
(A) which should run in a certain specified amount of time
(B) which avoids deadlocks
(C) where shared resources are accessed
(D) which must be enclosed by a pair of semaphore operations, P and V