Producer-consumer using condition variables, Operating System

Now let us present an implementation of a producer-consumer system using condition variables. This implementation works.



while (queue empty) {
wait(A, C) // atomically releases lock A and sleeps, waiting for
// condition variable C.
// When the thread wakes up, it re-acquires the lock.
// C is the condition variable that means ''queue not empty''.


In dequeue() above, if the thread wakes up and by chance the queue is empty, there is no problem: that's why we need the "while" loop.

Posted Date: 3/12/2013 5:17:31 AM | Location : United States

Related Discussions:- Producer-consumer using condition variables, Assignment Help, Ask Question on Producer-consumer using condition variables, Get Answer, Expert's Help, Producer-consumer using condition variables Discussions

Write discussion on Producer-consumer using condition variables
Your posts are moderated
Related Questions
Question: (a) i. Consider Active Directory as a database, then for each type and new class of objects, what is created? ii. What is the purpose of the global catalog? ii

What is real time system? A real time system has well explained, fixed time constraints. Processing must be done within the explained constraints, or the system will fail. It i

Consider a scenario of post mailbox, there are two processes named sender S and receiver R. Both processes can communicate with each other by name along with message. You need to I

Explain why SSTF scheduling tends to favor middle cylinders over the innermost and outermost cylinders. The center of the disk is the location having the fewest average distanc

What is banker's algorithm? Banker's algorithm is a deadlock avoidance algorithm that is applicable to a resource-allocation system with multiple examples of each resource type

A friend has promised to log in at a particular time. However, he needs to be contacted as soon as he logs in. The shell script checks after every minute whether he has logged in o

Q. Why would it be an awful idea for gateways to pass broadcast packets between networks? What would be the merite of doing so? Answer: All broadcasts would be spreads to all

Question: a) Define the term ‘Operating System' and identify two goals of an operating system. b) What do you understand by Symmetric multiprocessing (SMP) and Asymmetr

Demand paging With demand paging, a page is called into memory only when a location on that page is actually indexed during run time. With pre-paging, pages other than the one