GATE - 2007 | OS | Processes P1 and P2 use critical_flag in the following routine to

GATE - 2007 | OS | Processes P1 and P2 use critical_flag in the following routine to
Posted on 16-02-2022

GATE - 2007 [Operating System]

Question:

Processes P1 and P2 use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program.

get_exclusive_access ( )
{
    if (critical _flag == FALSE) {
        critical_flag = TRUE ;
        critical_region () ;
        critical_flag = FALSE;
    }
}


Consider the following statements.

  1. It is possible for both P1P1 and P2P2 to access critical_region concurrently.
  2. This may lead to a deadlock.

Which of the following holds?

  1. (i) is false (ii) is true
  2. Both (i) and (ii) are false
  3. (i) is true (ii) is false
  4. Both (i) and (ii) are true

Solution:

Option (C) is Correct.

Both the processes run concurrently if they run concurrently till the execution then there is no deadlock.

Thank You