In: Computer Science
If the value of semaphore is negative, ___?
A. an increment operation can be perform on it.
B. a process is waiting forever.
C. there will be no process waiting on that semaphore.
D. a decrement can be perform on it.
((( ( can negative semaphore decreases in case of more waiting processes? Explain in details. )))
If the value of semaphore is negative.......
B)A process is waiting forever.
Explaination:
If the semaphore value is negative, then the processes came for the execution on that semaphore will be blocked in waiting state. Semaphores are used for the process which are under the critical section problems that means process at which they have to share resources. The only possible values of semaphore is 0 and 1 in case of binary semaphore otherwise the semaphore value should be greater than or equal to 0. There will be 2 values for the semaphore variable. one is wait that allows the process to not allow into critical section when the other process is in critical section. The other is signal that means giving access for the processes to enter into the critical section. These two operations will possible only if the semaphore value is 0 or 1 respectively. Otherwise all processes that goes under that paricular semaphore which is having a negative value will wait for that semaphores signal. And that semaphore will unable to give access to the process at any moment. So we can say that If the value of the semaphore is negative, Then A process is waiting forever.
Hope the above is helpful. Please feel free to comment if any queries in the
comment section. I will try to solve them as soon as possible.
Do an up vote. Thank you...