Question: You will be implementing a Producer---Consumer program with a bounded buffer queue of N elements, P producer threads and C consumer threads (N, P and

You will be implementing a Producer---Consumer program with a bounded buffer queue of N elements, P producer threads and C consumer threads (N, P and C should be command line arguments to your program, along with three additional parameters, X, Puis and Ctime. that are described below). Each Producer thread should ngueueX different numbers onto the queue (spin waiting for Pune. cycles in between each call to ngueue). Each Consumer thread should Dequeue P*X/C items from the queue (spin---waiting for time cycles in between each call to Dequeue). The main program should create/initialize the Bounded Buffer Queue, print a timestamp, spawn off C consumer threads & P producer threads, wait for all of the threads to finish and then print off another timestamp & the duration of execution. Step 1: Write high level pseudocode for the Producer and Consumer threads, as well as for the Bounded Buffer Queue (Init, ngueue, Dequeue). Use semaphores to describe synchronization logic in your pseudocode, and put all of the calls to P/V in the bagueueDeaueuimplementations. Design a testing strategy for verifying that all of the threads are collectively executing correctly. One possible testing strategy is to have a single atomic counter (i.e. a counter with mutex synchronization so it is guaranteed to produce different numbers) to generate numbers for Producer threads, then have the main routine combine the output from all of the Consumer threads, sort it and verify that all of the input numbers appeared as output. Step 2. Implement your Producer---Consumer program using Linux threads. NEXT, modify your code by adding appropriate synchronization (mutex locks and/or signal semaphores and/or count semaphores) so that your code always executes correctly. Run your final program with 7 buffers (each of which can store one integer),5 producers, 3 consumers and values of X, Ptime and Ctine that are large enough so your program executes for a total of about 45 seconds on your VirtualB Implement your Producers/Consumers program using Linux Processes plus System V IPC Shared Memory You will be implementing a Producer---Consumer program with a bounded buffer queue of N elements, P producer threads and C consumer threads (N, P and C should be command line arguments to your program, along with three additional parameters, X, Puis and Ctime. that are described below). Each Producer thread should ngueueX different numbers onto the queue (spin waiting for Pune. cycles in between each call to ngueue). Each Consumer thread should Dequeue P*X/C items from the queue (spin---waiting for time cycles in between each call to Dequeue). The main program should create/initialize the Bounded Buffer Queue, print a timestamp, spawn off C consumer threads & P producer threads, wait for all of the threads to finish and then print off another timestamp & the duration of execution. Step 1: Write high level pseudocode for the Producer and Consumer threads, as well as for the Bounded Buffer Queue (Init, ngueue, Dequeue). Use semaphores to describe synchronization logic in your pseudocode, and put all of the calls to P/V in the bagueueDeaueuimplementations. Design a testing strategy for verifying that all of the threads are collectively executing correctly. One possible testing strategy is to have a single atomic counter (i.e. a counter with mutex synchronization so it is guaranteed to produce different numbers) to generate numbers for Producer threads, then have the main routine combine the output from all of the Consumer threads, sort it and verify that all of the input numbers appeared as output. Step 2. Implement your Producer---Consumer program using Linux threads. NEXT, modify your code by adding appropriate synchronization (mutex locks and/or signal semaphores and/or count semaphores) so that your code always executes correctly. Run your final program with 7 buffers (each of which can store one integer),5 producers, 3 consumers and values of X, Ptime and Ctine that are large enough so your program executes for a total of about 45 seconds on your VirtualB Implement your Producers/Consumers program using Linux Processes plus System V IPC Shared Memory
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
