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

Explain the booting process for a windows xp system, Q. Explain the booting...

Q. Explain the booting process for a Windows XP system? Answer: (1) Since the hardware powers on the BIOS begins executing From ROMand loads as well as executes the bootstrap

What is a real-time system?, What is a Real-time system? A Real-time sy...

What is a Real-time system? A Real-time system is used when inflexible time requirements have placed on the operation of processor or the flow of data so it is often used as a

DOS, Ask question #Minimum 500 words accepted#

Ask question #Minimum 500 words accepted#

Allocating new pages, Processes have valid and invalid entries on their pag...

Processes have valid and invalid entries on their page tables. The valid entries all point to some where "real" (e.g. a physical page, or some portion of disk in case of non-reside

How can the index blocks be implemented, How can the index blocks be implem...

How can the index blocks be implemented in the indexed allocation scheme? The index block can be implemented as follows a. Multilevel scheme b. Linked scheme c. Combin

What is an operating system, What is an operating system? An operating ...

What is an operating system? An operating system is a program that manages the computer hardware. It acts as an intermediate among users of a computer and the computer hardware

Producer – consumer process, Step by step displays the content, and the fin...

Step by step displays the content, and the final result of the list ("buffer") of 6 elements as the initial values ??and the following elements which are produced (NEXTP) or consum

Explain hashed page table method, Hashed page table method A general ap...

Hashed page table method A general approach for managing address spaces larger than 32 bits is to use a hashed page table with the hash values being the virtual-page number.

Determine the task of the pass ii in a two-pass assembler, Determine the ta...

Determine the task of the Pass II In a two-pass assembler Synthesize the target program is the task of the Pass II

Dynamically loadable kernel modules, Q. Dynamically loadable kernel module...

Q. Dynamically loadable kernel modules give elasticity when drivers are added to a system however do they have disadvantages too? Under what situations would a kernel be compiled

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