Question 40

CSMCQ2 marksNeeds review
Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is

. Three semaphores empty, full and mutex are defined with respective initial values of 0,

and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().
Producer:
Consumer:
do {<br> wait(P);<br> wait(mutex);<br> //Add item to buffer<br> signal(mutex);<br> signal(Q);<br>} while(1);
do {<br> wait(R);<br> wait(mutex);<br> //Consume item from buffer<br> signal(mutex);<br> signal(S);<br>} while(1);
Which one of the following assignments to P, Q, R and S will yield the correct solution?
Your answerChoose one option.

Log in to check the answer

You can attempt this question now. Sign in to view the answer key, explanations and discussion.Log in to check answer

EXPLORE & PRACTISE

Paper and topic context

See where this question comes from and choose what to practise next.

2018CS

GATE CSE 2018 · Paper 1

Computer Science and Information Technology · Original paper archive

Section
Computer Science and Information Technology
Question type
Multiple choice (MCQ)
Marks
2 marks

Practise related topics

Explore more previous year questions using this question’s imported topic tags.

computer science

GATE CSE previous year questions

information technology

GATE CSE previous year questions

computing

GATE CSE previous year questions

operating system

GATE CSE previous year questions

Comments

Ask a question, share your approach, or help someone understand.

Log in to view the discussion

You’re not logged in. Log in or create an account to see discussions and add comments.