A semaphore is a blocking synchronisation primitive. Describe how they work with the aid of pseudo-code. You can assume the existance of a thread_block() and a...

      

A semaphore is a blocking synchronisation primitive. Describe how they work with the
aid of pseudo-code. You can assume the existance of a thread_block() and a thread_wakeup()
function

  

Answers


Faith
Semaphores work by blocking processes with P, calling thread_block(), waiting for a resource if it is not
available, then being put into a queue of processes that want to access this resource. This is more
efficient than other solutions because we avoid busy waiting – other processes can do other things while
blocked ones are in the queue! When a resource is released, V is run, which calls thread_wakeup() to
signal the next thread to use it. See:
26420228303.PNG

Titany answered the question on April 26, 2022 at 05:35


Next: What is the producer consumer problem? Give an example of its occurrence in operating systems
Previous: Describe how to implement a lock using semaphores

View More Operating Systems Questions and Answers | Return to Questions Index


Exams With Marking Schemes

Related Questions