Producer-consumer using condition variables, Operating System

Assignment Help:

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.


Related Discussions:- Producer-consumer using condition variables

Process Management, In a table format, discuss the differences between th...

In a table format, discuss the differences between the fixed partition and the variable partition memory organization in terms of the basic idea, memory structure, advantages

What is busy waiting?, What is busy waiting? When strict alteration is ...

What is busy waiting? When strict alteration is done there may take place situation like two processes setting their flag as true. Therefore both of the processes have equal pr

Explain a computing environment, Q. Polling for an I/O completion is able ...

Q. Polling for an I/O completion is able to waste a large number of CPU cycles if the processor iterates a busy-waiting loop several times before the I/O completes. However if the

In which page replacement policy balady’s anomaly occurs, In which page rep...

In which page replacement policy Balady’s anomaly occurs? FIFO (First in First Out)

What kernel provide for an effective user level thread, 1. What must a kern...

1. What must a kernel provide for an effective user-level thread implementation? 2. With respect to the quantum q in a scheduling algorithm, explain and discuss the impact of th

Determine the syntax of the fork and join primitive, Determine the syntax o...

Determine the syntax of the Fork and Join Primitive  Answer: Syntax of the Fork and Join Primitive is as follow: Fork Join

Linux, write a linux command to display lines from 25 - 45 of directory "/e...

write a linux command to display lines from 25 - 45 of directory "/edc/password"

Batch oriented and interactive operating system., properies of Batch orient...

properies of Batch oriented and interactive operating system.

File management, five major activities on file management in operating syst...

five major activities on file management in operating system.? Explain it.?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd