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

Ipc, Explain in detail about ipc in linux

Explain in detail about ipc in linux

What are the benefits of multiprogramming?, What are the benefits of multip...

What are the benefits of multiprogramming? Responsiveness : Multithreading is an interactive application may permit a program to continue running even if part of it is block

What is external fragmentation?, What is external fragmentation? As pro...

What is external fragmentation? As process are removed from and loaded to the memory free memory space is bracken into pieces .external fragmentation take place when enough mem

What is busy waiting, What is busy waiting? The repeated implementation...

What is busy waiting? The repeated implementation of a loop of code while waiting for an event to happen is known as busy-waiting. The CPU is not engaged in any actual producti

Explain formal language grammar, Explain Formal Language Grammar A form...

Explain Formal Language Grammar A formal language grammar is a set of formation rules which explain which strings formed from the alphabet of a formal language are syntacticall

Describe the main architectural layers of windows xp, Q. Describe the three...

Q. Describe the three main architectural layers of Windows XP? Answer: (1) The HAL (Hardware Abstraction Layer) creates operating system portability by hiding hardware differ

Explain direct communication and indirect communication, Direct communicati...

Direct communication With direct communication each process that requires to communicate must explicitly name the recipient or sender of the communication. The send and receive

Explain deadlock avoidance, Deadlock Avoidance It's a method to evade ...

Deadlock Avoidance It's a method to evade deadlock by careful resource scheduling. This approach to the deadlock problem foresees deadlock before it actually occurs. This a

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