Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

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

Answer Attachments

Exams With Marking Schemes

Related Questions