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

Timers could be utilized to compute the current time, Q. Timers could be ut...

Q. Timers could be utilized to compute the current time. Provide a little description of how this could be accomplished. Answer: A program could utilize the following ap

Explain direct sequence-analog signal, 1. A digitized voice channel is made...

1. A digitized voice channel is made by digitizing a 7 KHz bandwidth analog signal. The signal is to be sampled twice the highest frequency (two samples per hertz) . Assume each sa

What is meant by demand paging? explain, What is meant by demand paging? Ex...

What is meant by demand paging? Explain. Demand paging is a technique to implement virtual memory. In demand paging simply when a page is required it is brought into memory. As

Can indefinite blocking take place, Consider the subsequent resource-alloca...

Consider the subsequent resource-allocation policy. Requests as well as releases for resources are allowed at any time. If a request for resources can't be satisfied because the re

Write note on process, Write note on process, process state? A process ...

Write note on process, process state? A process is in excess of the program code which is sometimes known as text section. It as well includes the current activity as represent

Explain about deadlock detection, Explain about deadlock detection? In ...

Explain about deadlock detection? In deadlock situation, the system must provide An algorithm that verifies the state of the system to verify whether a deadlock has occu

What is an i/o subsystem?, What is an I/O subsystem? The control of dev...

What is an I/O subsystem? The control of devices connected to the computer is a main issue while designing operating systems. Since I/O devices differ widely in their function

Operation management, #question After working for 30 years, Ramjee Somjee D...

#question After working for 30 years, Ramjee Somjee Dutt opted for VRS and started a courier company and did very well in the first four years. He was now looking for expansion of

Explain logical file system architecture, Logical File System Responsi...

Logical File System Responsible for providing the before discussed interface to the user including: File access. Directory operations. Security and protection.

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