(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
The post (Producer-Consumer problem)ObjectiveThe purpose of this project is to use synch appeared first on Get Papers.
Source: My posts