GATE Exam  >  GATE Questions  >  Consider two processes P0 and P1 which shares... Start Learning for Free
Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.
while (1)
{
while( flag!=1);
<critical section>
flag = i-1;
<remainder section>
}
If P0 starts executing first, which of the following holds by the above execution.
  • a)
    Mutual exclusion
  • b)
    Progress
  • c)
    Bounded wait
  • d)
    Both A and C
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Consider two processes P0 and P1 which shares a global variable &lsquo...
Mutual exclusion and bounded wait is guaranteed buy the given code.
Progress may not hold when only process is always interested to execute. process can not get consecutive execution of critical section due to after every execution turn is given to other process by making flag value to other.
View all questions of this test
Most Upvoted Answer
Consider two processes P0 and P1 which shares a global variable &lsquo...
Explanation:

Mutual Exclusion:
- The given code snippet ensures mutual exclusion by using the flag variable to control access to the critical section.
- When P0 enters the critical section, it sets the flag to 1, preventing P1 from entering.
- Similarly, when P1 enters the critical section, it sets the flag to 0, preventing P0 from entering.
- This ensures that only one process can be in the critical section at a time.

Progress:
- Progress is ensured in this scenario because if one process is in the critical section, the other process must wait until the flag value allows it to enter.
- Once a process exits the critical section, it updates the flag value to allow the other process to enter.
- This guarantees progress as both processes take turns entering the critical section.

Bounded Wait:
- Bounded wait is also satisfied in this situation because even though one process may have to wait for the other to finish executing the critical section, it is guaranteed to eventually get its turn.
- The waiting time is limited by the fact that the flag value will eventually change, allowing the waiting process to enter the critical section.
Therefore, the given code snippet satisfies both mutual exclusion and bounded wait properties, making option 'D' - Both A and C, the correct answer.
Explore Courses for GATE exam

Similar GATE Doubts

Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer?
Question Description
Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer?.
Solutions for Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.while (1){while( flag!=1);<critical section>flag = i-1;<remainder section>}If P0 starts executing first, which of the following holds by the above execution.a)Mutual exclusionb)Progressc)Bounded waitd)Both A and CCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev