Concurrency and Synchronization questions

Q31

GATE CS 2015 CS-3Concurrency and SynchronizationMCQ1 mark−1/3 if wrong
Two processes XX and YY need to access a critical section. Consider the following synchronization construct used by both the processes

Process X:
/* other code for process X */
while (true)
{
    varP = true;
    while (varQ == true)
    {
        /* Critical Section */
        varP = false;
    }
}
/* other code for process X */
Process Y:
/* other code for process Y */
while (true)
{
    varQ = true;
    while (varP == true)
    {
        /* Critical Section */
        varQ = false;
    }
}
/* other code for process Y */
Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?
Show answer without attempting

Answer: A

Q30

GATE CS 2015 CS-1Concurrency and SynchronizationNAT1 mark
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 ________.
Show answer without attempting

Answer: 3

0/20 correct0 marks

Related topics in Operating Systems