Producer-consumer using condition variables, Operating System

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

dequeue()

lock(A)

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''.
}

remove_item()
unlock(A)
enqueue()
lock(A)
insert_item()
signal(C)
unlock(A)

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
Define approaches that require knowledge of the system state?  Answer: Deadlock detection, Deadlock prevention, Deadlock Avoidance.


what topic i choose for os research proposal

Explain in detail about ipc in linux

Example 1.  The diagram illustrating the data structures of in-memory VFS objects and on-disk objects and their relationships on slide 24 of the lecture notes OSD.4. This diagram i

Virtual file systems The file-system execution having of three major layers. The first layer is the file-system interface, based on the open, read, write and close calls and fi

FIFO page replacement This is the easiest page replacement algorithm. Here the 1 st page toward the inside is the 1 st to leave that is the oldest page leaves. To execute th

Question: a) The following refers to optimization under Windows XP: i) Give five steps which could undertake to enhance overall system performance in a default Windows XP in

Q. Multithreading is a commonly utilized programming technique. Illustrate three different ways that threads could be implemented. Describe how these ways compare to the Linux clon

Define the Programming Fundamentals for Client- Server Developers Coding for client - server enforces good programming fundamentals. In order for applications to become client