Ask Question
17 March, 02:00

Some semaphore implementations provide a function getValue () that returns the current value of a semaphore. This function may, for instance, be invoked prior to calling wait () so that a process will only call wait () if the value of the semaphore is > 0, thereby preventing blocking while waiting for the semaphore. For example:

if (getValue (&sem) >0

wait (&sem);

What is the problem in this approach?

+4
Answers (1)
  1. 17 March, 04:08
    0
    Answer and Explanation:

    The values of the semaphore can always be 0 for a particular process A, because whenever process A checks the

    value by using getValue (&sem), some process B can be using the semaphore, after process B releases and puts

    the value to 1, some other process C can get that semaphore by seeing the value > 0 and decrements its value

    to 0 again. Now If the process A comes again It will see the value to be 0 again and this can go on ...

    process A will never get the semaphore.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Some semaphore implementations provide a function getValue () that returns the current value of a semaphore. This function may, for ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers