Concurrency and Synchronization questions

Q31

GATE CS 2014 CS-2Concurrency and SynchronizationMCQ2 marks−2/3 if wrong
Consider the procedure below for the Producer-Consumer problem which uses semaphores:
semaphore n = 0;
semaphore s = 1;

void producer()
{
    while(true)
    {
        produce();
        semWait(s);
        addToBuffer();
        semSignal(s);
        semSignal(n);
    }
}

void consumer()
{
    while(true)
    {
        semWait(s);
        semWait(n);
        removeFromBuffer();
        semSignal(s);
        consume();
    }
}
Which one of the following is TRUE?
Show answer without attempting

Answer: C

0/10 correct0 marks

Related topics in Operating Systems