Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  A counting semaphore was initialized to 10. T... Start Learning for Free
A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore is
  • a)
    0
  • b)
    8
  • c)
    10
  • d)
    12
Correct answer is option 'B'. Can you explain this answer?
Verified Answer
A counting semaphore was initialized to 10. Then 6 P (wait) operations...
Initially we have semaphore value = 10 Now we have to perform 6 p operation means when we perform one p operation it decreases the semaphore values to one. So after performing 6 p operation we get, semaphore values = 10 - 6 = 4 and now we have to perform 4 v operation means when we perform one V operation it increases the semaphore values to one. So after performing 4 v operation we get, semaphore values = 4 + 4 = 8. Option (B) is correct.
View all questions of this test
Most Upvoted Answer
A counting semaphore was initialized to 10. Then 6 P (wait) operations...
Semaphore Operations

- A semaphore is a synchronization tool used for interprocess communication.
- A semaphore is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system.
- A semaphore is simply a value in a designated place in operating system (or kernel) storage that each process that uses the semaphore can check and then change.
- Depending on the value that is found, the process can use the resource or will find that it is already in use and must wait for some period before trying again.

P (wait) Operation

- The P (wait) operation decrements (i.e., reduces) the semaphore value by 1.
- If the semaphore value is greater than 0, the P operation will complete immediately and the semaphore value will be decremented.
- If the semaphore value is 0, the P operation will block (i.e., wait) until the semaphore value becomes greater than 0.

V (signal) Operation

- The V (signal) operation increments (i.e., increases) the semaphore value by 1.
- If there are any processes waiting on the semaphore, the V operation will unblock (i.e., wake up) one of the waiting processes.
- If there are no processes waiting on the semaphore, the V operation will simply increment the semaphore value.

Solution

- The counting semaphore was initialized to 10.
- 6 P (wait) operations were completed on this semaphore, which means the semaphore value was decremented by 6.
- The resulting value of the semaphore after the P operations is 10 - 6 = 4.
- 4 V (signal) operations were then completed on this semaphore, which means the semaphore value was incremented by 4.
- The resulting value of the semaphore after the V operations is 4 + 4 = 8.
- Therefore, the correct answer is option B - 8.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer?
Question Description
A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. 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 A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. 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 A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer?.
Solutions for A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. 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 A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer?, a detailed solution for A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice A counting semaphore was initialized to 10. Then 6 P (wait) operations and 4 V (signal) operations were completed on this semaphore. The resulting value of the semaphore isa)0b)8c)10d)12Correct answer is option 'B'. 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