Ask Question

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. 28 March, 13:31
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers