Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Two processes, P1 and P2, need to access a cr... Start Learning for Free
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v
   /* P1 */
while (true) {
     wants1 = true;
     while (wants2 == true);
     /* Critical
         Section */
    wants1=false;
}
/* Remainder section */
/* P2 */
while (true) {
    wants2 = true;
    while (wants1==true);
     /* Critical
        Section */
     wants2 = false;
}
/* Remainder section */
  • a)
    It does not ensure mutual exclusion.
  • b)
    It does not ensure bounded waiting.
  • c)
    It requires that processes enter the critical section in strict alternation.
  • d)
    It does not prevent deadlocks, but ensures mutual exclusion.
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Two processes, P1 and P2, need to access a critical section of code. C...
Bounded waiting :There exists a bound, or limit, on the number of times other processes are allowed to enter their critical sections after a process has made request to enter its critical section and before that request is granted. mutual exclusion prevents simultaneous access to a shared resource. This concept is used in concurrent programming with a critical section, a piece of code in which processes or threads access a shared resource. Solution: Two processes, P1 and P2, need to access a critical section of code. Here, wants1 and wants2 are shared variables, which are initialized to false. Now, when both wants1 and wants2 become true, both process p1 and p2 enter in while loop and waiting for each other to finish. This while loop run indefinitely which leads to deadlock. Now, Assume P1 is in critical section (it means wants1=true, wants2 can be anything, true or false). So this ensures that p2 won’t enter in critical section and vice versa. This satisfies the property of mutual exclusion. Here bounded waiting condition is also satisfied as there is a bound on the number of process which gets access to critical section after a process request access to it. 
View all questions of this test
Most Upvoted Answer
Two processes, P1 and P2, need to access a critical section of code. C...
Explanation:

The given synchronization construct has two shared variables, wants1 and wants2, which are initialized to false. The processes P1 and P2 use these variables to enter their critical sections in a mutually exclusive manner. However, this construct has some limitations and does not provide complete synchronization. Let's discuss each option and why it is true or false.

a) It does not ensure mutual exclusion:
The mutual exclusion property ensures that only one process can execute its critical section at a time. In the given construct, mutual exclusion is achieved because a process can enter its critical section only if the other process is not interested in entering its critical section. This is ensured by the while loop, which checks the value of the other process's wants variable. Therefore, option (a) is false.

b) It does not ensure bounded waiting:
The bounded waiting property ensures that there is a limit on the number of times a process can be prevented from entering its critical section. In the given construct, there is no such limit on the waiting time of a process. A process can be prevented from entering its critical section indefinitely if the other process keeps setting its wants variable to true. Therefore, option (b) is true.

c) It requires that processes enter the critical section in strict alternation:
Strict alternation means that the processes take turns entering their critical sections in a fixed order. In the given construct, there is no such fixed order of entering the critical section. A process can enter its critical section multiple times in a row if the other process does not want to enter its critical section. Therefore, option (c) is false.

d) It does not prevent deadlocks, but ensures mutual exclusion:
A deadlock is a situation where two or more processes are blocked and cannot proceed because they are waiting for each other to release a resource. The given construct can lead to a deadlock if both processes set their wants variables to true at the same time. In this case, both processes will wait indefinitely in their while loops, and the system will be deadlocked. However, mutual exclusion is still ensured because only one process can execute its critical section at a time. Therefore, option (d) is true.

In summary, the given synchronization construct provides mutual exclusion but has a limitation in ensuring bounded waiting and may lead to deadlocks in certain scenarios.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer?
Question Description
Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer?.
Solutions for Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer?, a detailed solution for Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes:Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?v /* P1 */while (true) { wants1 = true; while (wants2 == true); /* Critical Section */ wants1=false;}/* Remainder section *//* P2 */while (true) { wants2 = true; while (wants1==true); /* Critical Section */ wants2 = false;}/* Remainder section */a)It does not ensure mutual exclusion.b)It does not ensure bounded waiting.c)It requires that processes enter the critical section in strict alternation.d)It does not prevent deadlocks, but ensures mutual exclusion.Correct answer is option 'D'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
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