GATE Exam  >  GATE Questions  >  A counting semaphore was initialized to 0, th... Start Learning for Free
A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:
  • a)
    18
  • b)
    20
  • c)
    0
  • d)
    2
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
A counting semaphore was initialized to 0, then 20 V operations were s...
20V => increments the semaphore 20 times. Hence , the value becomes 20. 18P => decrements the semaphore 18 times. Hence , the value becomes 2.
View all questions of this test
Most Upvoted Answer
A counting semaphore was initialized to 0, then 20 V operations were s...
The counting semaphore is a synchronization primitive used for controlling access to a shared resource. It is initialized with a non-negative integer value and supports two operations: P (proberen) and V (verhogen).

Explanation:
- The counting semaphore is initialized to 0, which means that there are no available resources initially.
- 20 V operations are successfully completed on this semaphore. The V operation increments the value of the semaphore by 1, representing the release of a resource. So, after 20 V operations, the value of the semaphore becomes 20.
- 18 P operations are then performed on the semaphore. The P operation decrements the value of the semaphore by 1, representing the acquisition of a resource. However, since the initial value of the semaphore was 0 and there were only 20 resources available, only 18 P operations can be successfully completed. The remaining 2 P operations will be blocked until more resources are released.
- The resulting value of the semaphore is the initial value plus the number of successful V operations minus the number of successful P operations. In this case, the initial value is 0, there were 20 successful V operations, and 18 successful P operations. Therefore, the resulting value is 0 + 20 - 18 = 2.

Conclusion:
- The resulting value of the semaphore after 20 V operations and 18 P operations is 2 (option D).
Explore Courses for GATE exam

Similar GATE Doubts

A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer?
Question Description
A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct 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 A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct 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 A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer?.
Solutions for A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct 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 A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer?, a detailed solution for A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer? has been provided alongside types of A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice A counting semaphore was initialized to 0, then 20 V operations were successfully completed on this semaphore, followed with 18 P operations, the resulting value of the semaphore is:a)18b)20c)0d)2Correct 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