operating system read the posted question below. there is a sample as well for help. read it carefully.

  • Bids0
  • Budget $0.00
  • Average Bid $0.00

Posted on

Active
Bid

Project Desciption

CMPSC 3113 Operating Systems

Assignment #2- Implementation of the Producer-Consumer ProblemNon-Threading implementation

In this assignment you are required to implement the Producer Consumer Problem as discussed in class.

Assume that there is only one Producer and there is only one Consumer.

The problem you will be solving is the bounded-buffer producer-consumer problem. You are required to implement this assignment in Java or in C/C++. This buffer can hold a fixed number of items. This buffer needs to be a first-in first-out (FIFO) buffer. You should implement this as a Circular Buffer that satisfies the FIFO. There should be exactly one instance of the buffer. The producer and the consumers must reference the same buffer.
The producer is responsible for producing data items to be added to the buffer. If the buffer is full, the producer must wait for a consumer to consume at least one item before it can add a new item to the buffer. The producer is required to produce a given number of items. The item that the producer adds to the buffer is a random uppercase letter ‘A’ to ‘Z’, inclusive. When a producer successfully inserts an item in the buffer it should print the location of insertion and time when insertion occurs with nanosecond resolution, using this format (spaces matter):Producer inserted ‘S’ at index 0 at 323187855 ns
The consumer is responsible for consuming elements, generated by the producer, from the buffer. If the buffer is empty, the consumer must wait for the producer to add an item to the buffer. When a consumer successfully removes an item from the buffer it should print the location of removal and time when removal occurs with nanosecond resolution, using this format:Consumer consumed ‘I’ at index 7 at 324491579 ns
Implement the Producer and the Consumer as two separate functions (no multithreading).
The main driver (function) must do all necessary initialization, then it must iterate for a period of 10seconds (not 10 iterations).
In each iteration, the main driver calls randomly either the Producer function or the Consumerfunction. Once either of these two functions is called, it should return within one second time period from the times that it has been called as specified below:If the corresponding function (Producer/Consumer) is successful in Producing/Consuming an item (character) before the one second is expired, then the function will return normally.Otherwise (in case of the Buffer is Full/Empty and the one second period has expired), then the corresponding function should return to the main driver without Producing/Consuming and item.
Sample Output:
Start time in nanosecond: 443727532 ns
Producer inserted ‘G’ at index 0 at 443729161 ns Producer inserted ‘Q’ at index 1 at 443730194 ns Producer inserted ‘R’ at index 2 at 443761114 ns Consumer consumed ‘G’ at index 0 at 443763544 ns Consumer consumed ‘Q’ at index 1 at

Employer Information

2325 project(s) posted hire 2 freelancers
Member since: 2020-02-01
FREELANCER BIDDING (0)

There are no bids yet.

Open chat
1
Whatapp Us
Hey? You want your project done, Whatsapp us Now.
Click to Submit a Project