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

Why system calls have to be implementing by a interpreter, Q. What system c...

Q. What system calls have to be implementing by a command interpreter or shell in order to start a new process? Answer: In the UNIX systems a fork system call followed by an ex

Memory management, diffenciet between least recently used and not recently ...

diffenciet between least recently used and not recently used

Do ratio analysis of financial statements, Do ratio analysis by comparing t...

Do ratio analysis by comparing the four companies financial statements, analysis and interpretation on the four-basic group : (Refer to attachment A) Liquidity ratio Asset

Memory management unit, When a program issues a memory load or store operat...

When a program issues a memory load or store operation, the virtual addresses (VAs) used in those operations have to be translated into "real" physical memory addresses (PAs). This

What kind of operating system is windows xp, Q.  What kind of operating sy...

Q.  What kind of operating system is Windows XP? Describe two of its major features. Answer: A 32 or 64 bit pre-emptive multitasking operating system supporting multiple use

Difference between internal and external fragmentation, Explain the differe...

Explain the difference between internal and external fragmentation. Internal Fragmentation is the area in a region or a page that is not used by the job occupying that region o

How does user specify block to be fetched in direct access, How does user s...

How does user specify block to be fetched in direct access? By specifying the relative block number, relative to first block in file, which is block 0.

How many cubic feet of storage space would require, Q. Presume that we agr...

Q. Presume that we agree that 1 kilobyte is 1,024 bytes 1 megabyte is 1,0242 bytes and 1 gigabyte is 1,0243 bytes. This progression carries on through terabytes, petabytes, and ex

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