Producer - consumer synchronization, Operating System

Assignment Help:

This assignment is based on Programming Project 6.40 in Silbershatz. Implement the ProducerXConsumer program according to the instructions for Project 6.40 for both Linux and Win32 threads. (1) However BEFORE you add any synchronization to your code use sleep()/usleep() calls to force your code to produce as many different types of synchronization bugs as possible.  Use the output produced by your program and for your Linux implementation only also use 'strace -f' to explain how and where in your code the synchronization bugs occur.  Be sure to use the command line argument for strace - see the man pages for details on this Each of your threads should fprint out a line of output to stderr when it is first started, and again when each buffer of input/output is processed.  

Submit code and annotated  test output for these experiments explaining where the race conditions occur.

NEXT, modify your code by adding appropriate synchronization (mutex locks and/or signal semaphores and/or count semaphores) so that it always executes correctly.   Use diff on Linux & comp on Windows to verify that the input & output files are identical by annotating your trace output clearly and concisely and using diff/comp to compare the contents of the input & output files.  Explain the logic of how you synchronized your code in your design documentation by submitting high level pseudocode with semaphore synchronization (init, p(), v()) and an explanation of the logic that you used; (2)  submit wellXcommented source code and annotated output (including strace listings) to demonstrate that your code is executing correctly, despite the sleep/usleep commands from the previous part.

Run your final program with 3 buffers (each of which is 13 bytes long),  6 producers, 3 consumers and a file that contains about 200 bytes; annotate & submit this output. (3) For the third part of this assignment, modify your synchronization so that a deadlock condition occurs, and document this situation by explaining in your design documentation how deadlock was produced in your code and how it can be avoided.


Related Discussions:- Producer - consumer synchronization

What is a multiprocessing system, What is a multiprocessing system? Mul...

What is a multiprocessing system? Multiprocessor systems are those systems that use additional than a single processor for program execution. It is done for raising the executi

Deadlocks, At the end of this lecture, and into the next lecture, we will d...

At the end of this lecture, and into the next lecture, we will discuss the last major type of logical error that can occurwhen programming with threads. A deadlock occurswhen two t

Describe the technique of packing, Describe the technique of packing. T...

Describe the technique of packing. The physical record size will not accurately match the length of the desired logical record and the Logical records may even differ in length

How is memory management done using bit maps?, How is memory management don...

How is memory management done using bit maps? A bit map is here in this we signify the bit value as 0 or 1. 1-hole 0-process In this we are able to represent the proce

Multi-level page tables, Multi-level page tables are tree-like structures t...

Multi-level page tables are tree-like structures to hold page tables. As an example, consider a two- level page table, again on a 32-bit architecture with 212 = 4 kbyte pages. Now,

Describes attributes, What are attributes? Attributes are the one, whic...

What are attributes? Attributes are the one, which explains the properties of data object.

Define fifo page replacement algorithm, Define FIFO Page Replacement Algori...

Define FIFO Page Replacement Algorithm This policy simply eliminates pages in the order they arrived in the main memory. By using this policy we simply remove a page based upo

Diehard allocator - custom allocators, Allocators can also be used to avoid...

Allocators can also be used to avoid problems with unsafe languages. C and C++ are pervasive, with huge amounts of existing code. They are also memory-unsafe languages, in that the

Why do systems store the operating system in firm ware, Q. Why do several s...

Q. Why do several systems store the operating system in firm ware and others on disk? Answer: For certain devices such like handheld PDAs and cellular telephones a disk with

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

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