(Producer-Consumer problem)ObjectiveThe purpose of this project is to use synchronization mechanisms to solve the problem ofproducer-consumer.DescriptionDevelop a program with 4 threads, two producer threads and two consumer thread. Theprogram generate only even numbers and place them into the shared buffer between theproducer 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 overflowThe two consumer threads print even numbers on the screen . Here, it is important toconsider the following:1) No consumer thread re-print the element has been printed by the other consumerthread.2) Threads should print all the elementYour 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 bufferX=0 // initial value for generation of the even numbers, itcan 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 thenumberFor example8, 52210, 523Where 8 & 10 represent the even numbers while 522 & 523 represent theids of the threads printed 8 and 10 respectively
Plagiarism-free and delivered on time!
We are passionate about delivering quality essays.
Our writers know how to write on any topic and subject area while meeting all of your specific requirements.
Unlike most other services, we will do a free revision if you need us to make corrections even after delivery.
How it Works
Place an order
Fill out the order form.
Attach any custom instructions that is required to complete your order.
Pay online safely.
The order form will redirect you to a payment page.
Receive Order via Email
Once the order is complete, we’ll send it via the email provided on the order form.