Question: This second assignment focus is on threads and their synchronization. pthreads on Linux to implement your assignment. Make use of You are asked to implement

This second assignment focus is on threads and their synchronization. pthreads on Linux to implement your assignment. Make use of You are asked to implement 4 (four) threads that we call "providers" and a simple-main-program for 260 (two-hundreds and sixty) threads that we call "buyers". The providers threads produce different integer-numbers and put them in a queue. Design and implement a program that will handle the synchronization se of the providers' threads as well as the buyers threads. Basically the program should make sure that only one provider inserts an item (here an integer identifying/representing the item) and prints it on the screen, and also makes sure only one buyer at a time buys the integer and prints it on the screen. The other providers (threads) should sleep for some time while the thread buyer is buying. When a thread wakes up, it tries to buy an integer from the queue. Make sure thatH each and all buyers get a chance to buy an item, represented by a number. No buyer should make the other ones starve. The provider should not stop providing items (i.e. numbers representing items). Make sure that that each and all of the providers gets a chance to insert items (i.c. numbers) whe hes rav Your program should have one command-line argument which specifies the bues notification to the provider threads to start providing integers and then notifies tite integers number N of buyer threads. When the program starts, it creates N+2 threads which place themselves in a thread pool. The main program issues the initial the main-program to start doing its job as described above by making sure that the N buyer threads have a chance to buy items (represented by numbers). 2. After keeping a copy of program-1, from part-1 above (of course that will be needed in the report for part-1), modify the program of part-1 and run it in the case of one single provider and 6 buyers. Explain in your report what will be one main significant change to your code to make it efficient, if any? Note: For extra credits you are encouraged to be creative. Crical You haue too Sema phaes Sect ion for I a need a mutex tor each location acces
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
