Question

What “wait” operation is called, the semaphore value: Increases by 1 Decrease by 1

  1. What “wait” operation is called, the semaphore value:
  1. Increases by 1
  2. Decrease by 1
0 0
Add a comment Improve this question Transcribed image text
Answer #1

A semaphore is a special kind of synchronization data that is used through special primitives. Semaphore is used to implement mutual exclusion, it also lacks race conditions and also implements control synchronization. A semaphore is a shared integer variable with non negative values that is accessed through increment and two atomic operations - Wait (P : from dutch proberon means to test condition by decrement) and Signal (V : from verhogen means to increment).

when a process performs a wait operation, the operations checks that whether the value of semaphore is > 0. If so, it decrements the value of semaphore and let the process execution be completed, else it blocks the process on the semaphore. On the other hand, the signal operation when called, activates a blocked process on the semaphore, if any, and increments the value of semaphore by 1. Atomicity of wait and signal operations is ensured by the programming language being used or the operation system implementing it.

operation P (S)

begin

if S>0

then S=S-1;

else block the process on S;

end;

operation V (S)

begin

if some process is blocked on S then activate one blocked process;

else S=S+1;

end;

So, now it should be clear that when wait operation is called it just test the condition and decreases the value by 1.

Many classical problems of process synchronization are implemented either by counting or general semaphore and binary semaphore.

Add a comment
Know the answer?
Add Answer to:
What “wait” operation is called, the semaphore value: Increases by 1 Decrease by 1
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT