Question

Why are semaphore P(), V() operations implemented using hardware atomic functions?

Why are semaphore P(), V() operations implemented using hardware atomic functions?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Semaphores with unary P or P() and V or V() operations are implemented with atomic hardware and code or simply, hardware atomic functions as, an atomic operation is indivisible as it is considered to execute as a single unit. After the initialization of a counting semaphore- a synchronization object with an integer value, is accessed through two different operations- P and V, also called and mean, down and up, decrement and increment, wait() and signal(), or acquire and release, respectively.

In this case, semaphores are implemented with hardware support. Other processes are not allowed to access the semaphore while either P or V is executing. Disabling interrupts do not work for a shared-memory multiprocessor system hence, atomic hardware instructions are used. Atomic operations are made sure temporarily suspending pre-emption or disabling hardware interrupts on uniprocessor systems.

This particular implementation ensures the atomicity of the increment, decrement, and comparison operations thus, reducing a risk of increments or decrements being forgotten, or the semaphore value becoming negative. Atomicity is achieved using a machine instruction that can read, modify, and write the semaphore in a single operation.

Add a comment
Know the answer?
Add Answer to:
Why are semaphore P(), V() operations implemented using hardware atomic functions?
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