GATE Exam  >  GATE Questions  >  Each of a set of n processes executes the fol... Start Learning for Free
Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.

What does the code achieve?
  • a)
    It ensures that at most two processes are in CODE SECTION Q at any time.
  • b)
    It ensures that all processes execute CODE SECTION P mutually exclusively.
  • c)
    It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.
  • d)
    It ensures that at most n – 1 processes are in CODE SECTION P at any time.
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Each of a set of n processes executes the following code using two sem...
All the processes running the given code will remain block due to wait(b) until the value of count becomes n.
When the value of count will become equals to n, value of b changes to 1 which will subsequently allow a process to go into section Q.
Hence, no process can go to section Q until all the process executes code section P.
View all questions of this test
Explore Courses for GATE exam

Similar GATE Doubts

Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer?
Question Description
Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. 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 Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer?.
Solutions for Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. 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 Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer?, a detailed solution for Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Each of a set of n processes executes the following code using two semaphores a and b initialized to 1 and 0, respectively. Assume that count is a shared variable initialized to 0 and not used in CODE SECTION P.What does the code achieve?a)It ensures that at most two processes are in CODE SECTION Q at any time.b)It ensures that all processes execute CODE SECTION P mutually exclusively.c)It ensures that no process executes CODE SECTION Q before every process has finished CODE SECTION P.d)It ensures that at most n – 1 processes are in CODE SECTION P at any time.Correct answer is option 'C'. 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