Ask Question
12 June, 01:45

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?

+3
Answers (1)
  1. 12 June, 02:27
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers