Question: We are writing a thread - safe queue. We are using a mutex lock and a condition variable nonempty. Our function dequeue ( ) should
We are writing a threadsafe queue. We are using a mutex lock and a condition variable nonempty. Our function dequeue should block if the queue is empty length until another threads adds a value to the queue and signals nonempty. Which of the following code fragments will accomplish this? We are writing a threadsafe queue. We are using a mutex lock and a condition variable nonempty. Our function dequeue should block if the queue is empty length until another threads adds a value to the queue and signals nonempty. Which of the following code fragments will accomplish this? pthreadcondwait&nonempty, &lock; if length pthreadcondwait&nonempty, &lock; while length pthreadcondwait&nonempty, &lock; do pthreadcondwait&nonempty, &lock; while length ; All of the above None of the above
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
