Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
(Producer-Consumer problem) Objective The purpose of this project is to use synchronization mechanisms to solve the problem of producer-consumer.
(Producer-Consumer problem)
Objective
The purpose of this project is to use synchronization mechanisms to solve the problem of
producer-consumer.
Description
Develop a program with 4 threads, two producer threads and two consumer thread. The
program generate only even numbers and place them into the shared buffer between the
producer and consumer. It is important to consider the following:
1) Both producer threads use the same variable, e.g. x, to generate the even numbers.
2) No producer thread overwrite what has been written by other producer thread.
3) No producer thread exceeds the limit of the buffer, i.e., no buffer overflow
The two consumer threads print even numbers on the screen . Here, it is important to
consider the following:
1) No consumer thread re-print the element has been printed by the other consumer
thread.
2) Threads should print all the element
Your program will output the following in a standardized format.
a. All even numbers produced by producer threads.
b. Associate the thread id with number that print it .
c. Every number is only printed once.
Here is the Sample input file:
N =5 // size of the shared buffer
X=0 // initial value for generation of the even numbers, it
can be any values.
Here is how the program should be run.
Here is the sample output.
All even numbers associated with id of the thread that printed the
number
For example
8, 522
10, 523
Where 8 & 10 represent the even numbers while 522 & 523 represent the
ids of the threads printed 8 and 10 respectively