Explain in detail how binary semaphores and binary semaphore operations can be implemented in the kernel of an operating system.
What will be an ideal response?
The kernel will have to allocate a bit to represent the value of the semaphore as well as a queue to organize the threads that are blocked for the semaphore.This queue can just be implemented as a linked list of PCBs.When a thread calls the P command, the kernel can disable interrupts. If the value of the semaphore is 0, the thread can be added to the end of the blocked queue and removed from the ready queue. Then interrupts can be re-enabled. If the value of the semaphore is 1, the thread sets the value of the semaphore to be 0, then re- enables interrupts. When a thread calls the V operation, the kernel first disables interrupts. Then the kernel checks to see if the blocked queue is empty. If it is, the value of the semaphore is set to 1,and interrupts are re-enabled. If there is a thread blocked for the semaphore, the kernel can remove that thread from the queue, place the thread in the ready queue, then re-enable interrupts.
You might also like to view...
When grouping controls, a user can select the ________ layout format that mimics a paper form with labels to the left of each field
Fill in the blank(s) with correct word
The ________ is an Excel add-in that offers powerful tools for statistical analysis
Fill in the blank(s) with correct word
A loopback plug is ____. (Select two.)
A) Commonly used with the older ports B) Used to test the motherboard for moderate power consumption C) Commonly used to determine whether the RAM modules are compatible D) Used to test a communication circuit port or to test network port functionality E) Used when POST diagnostics only provide beep codes
How is the connection of multiple terminals to the serial interface simulated in Linux?
What will be an ideal response?