Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are given three ( 3 ) processes in one program that work together to solve a producer consumer problem. Two Processes are producers ,
You are given three processes in one program that work together to solve a producer consumer problem. Two Processes are producers each producing its own type of product in a continuous loop. That is one product type produced by one producer and a different product type by the other producer.
One Process is a consumer of products. The consumer process consists of five threads.
One thread is a distributor thread
Two threads consume one type of product. That is each of these two threads consumes only product type
Two threads consume a second type of product. That is each of these two threads consumes only product type
The consumer process contains two product storage buffers, each comprised of a fixed number of slots. The number of slots in the buffers are to be different one has more slots than the other You choose and specify the number of slots in each buffer as a definition in your program solution
Communication between the producer processes and the consumer process is to be through a single pipe This single, shared pipe is used to communicate between each producer process and the consumer process. Each producer process writes into this pipe the product to be consumed by the consumer process.
Synchronization
This project includes features of the consumerproducer problem that we have discussed in class. There are different approaches that one can take to implement the necessary synchronization. But, for this project, you are to use condition variables to achieve synchronization and locks to provide the associated mutual exclusion for all concurrent accesses.
Access to each buffer in the consumer process is to be shared among the associated two product consumer threads and the distributor thread. The access must be done safely with no race conditions.
Program Output
Products that are consumed by the product consumer threads are to be logged to a file. The file is to be your design, but contains data as follows. Each product consumer thread writes to the file: the product type, the consumption thread ID the production sequence number producer count value and the consumption sequence number the counter value for consumption of that product item These values can help you evaluate whether you are losing data and the way that your program is producing and consuming data.
Deliverables:
Week deliverable includes: the creation of all processes and the pipe communication among processes; the design of the two consumer storage buffers; read and write getput functions for the two buffers,
Week deliverable includes: the product distributor thread, the product consumer threads; locks for mutual exclusion where needed and condition variable code where needed.
Week Final program delivery: integration of all of the processes, threads, and storage buffers; output file design, file data record design and write functions; sample data runs with output files; logs showing testing comparisons.
Grading Rubric:
Creation of processes
implementation of loop delays in the producer processes
Termination send
Creation of the Distribution thread
Pipe communication
send to pipe
receive from pipe
Create circular buffers
get and put functions
Creation of worker threads
Buffer write synchronization using conditional variables
use of lock
Access to consumer product counters
mutual exclution using locks foir read and write
separate locks per counter
File output
creation of the output file
creation of record structure for file writes
write to output file
Proper shutdown mechanism
Do week one in C thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started