Home » Operating Systems » Operating systems miscellaneous » Question

Operating systems miscellaneous

  1. Two processes P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes :
    /* P1 *//* P2 */
    while (true) { while (true){
    wants1 = true; wants2 = true;
    while while (wants 1 = = true);
    (wants2 = = true); /* Critical
    /* Critical Section */
    Section */ wants2 = false;
    wants1 = false;   } /* Remainder section */
    } (/* Remainder Section)

    Here, wants1 and wants2 are shared variables, which are initialized to false,
    Which one of the following statements is true about the above construct?
    1. it does not ensure mutual exclusion
    2. it does not ensure bounded waiting
    3. it requires that processes enter the critical section in strict alternation
    4. it does not prevent deadlocks, but ensures mutual exclusion
Correct Option: D

Wants2 enters the critical section, if process P1 ’s variable wants1 is true and if wants2 is true then wants1 enters critical section. In both cases, there will be deadlock but no mutual exclusion.



Your comments will be displayed only after manual approval.