In: Computer Science
This is a multiple answer question, meaning any of the 4 statements could be true. From O/S class
A semaphore, in its purest form (like the one we used in the Dining Philosopher's solution), is what
A busy waiting lock. |
||
An atomic integer that has two functions it can use - one that increments it by 1 and one that decrements it by 1. |
||
A Monitor |
||
An atomic integer that can be changed to any value from any other value directly. |
Semaphore is not a busy waiting lock. The semaphore has a data structure struct semaphore {int var;queue blockedq;};. The semaphore puts and releases processes with the help of the blocked queue and no process will continuously poll to check the resource is free or not
Yes semaphore is an atomic integer. It can only be incremented or decremented at a time. And there can be functions associated to each operation like putting process into a blocked queue or releasing the process from a blocked queue, etc.,.
It is not a monitor. Monitor is a thread container that will allow one thread to execute at any time. But semaphore is not a thread container and it will let more than one process or thread to access a resource based on its value.
It's atomic integer. But its value cannot be changed from any value to any value. Rather increment and decrement operations are only operations that are allowed.
Therefore only option (b) is true