Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a simple program to illustrate one producer and one consumer problem. The producer will produce 100 messages for the consumer to consume. Use an

Implement a simple program to illustrate one producer and one consumer problem. The producer will produce 100 messages for the consumer to consume. Use an array of 10 slots to hold the contents of the buffer. The producer should send a sequence of integers to the consumer. Specifically, it should send the sequence 1, 2, 3, ..., 100, in that order. The consumer should receive them and check that it has indeed received exactly that sequence, in that order. Implement the program in two ways. 1. not thread-safe, not protecting the buffer; 2. using mechanism to protect the critical sections while they are updated. Figure 2-32 (page 138) of the textbook gives a solution for a single buffer producer-consumer problem using semaphores and conditional variable. Figure 2-35 gives a Java solution using monitors. You may construct your program based on these examples. Assume that it takes a random time between (0, 1) second to produce an item, and (0, 1) second to consumer an item. Notes: 1. You may use any programming language, as long as there is a way to to turn off protection on synchronization; 2. You may increase the number of producers and consumers for additional bonuses;

i NEED THE BONUS AS WELL.tHANKYOU

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago