The following is a code with two threads, producer and consumer, that can run…
GATE · 2008 · IT
The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V operations.
semaphore S = 1, Q = 0;
integer x;producer: | consumer: |
|---|---|
|
|
|
|
|
|
|
|
|
|
Which of the following is TRUE about the program above?
- A.
The process can deadlock
- B.
One of the threads can starve
- C.
Some of the items produced by the producer may be lost
- D.
Values generated and stored in 'x' by the producer will always be consumed before the producer can generate a new value
Attempted by 217 students.
Sign up free to check your answer
Sign up freeLoading lesson…