Question: Part 2. This assignment is (very roughly) based on Programming Project 6.40 in Silbershatz. You will be implementing a Producer-Consumer program with a bounded buffer

 Part 2. This assignment is (very roughly) based on Programming Project6.40 in Silbershatz. You will be implementing a Producer-Consumer program with a

Part 2. This assignment is (very roughly) based on Programming Project 6.40 in Silbershatz. 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, Ptime and Ctime, that are described below). Each Producer thread should Enqueue X different numbers onto the queue (spin-waiting for Ptime cycles in between each call to Enqueue). Each Consumer thread should Dequeue P*X/C items from the queue (spin-waiting for Ctime 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, Enqueue, Dequeue). Use semaphores to describe synchronization logic in your pseudocode, and put all of the calls to P/V in the Enqueue/Dequeue implementations. Submit this pseudocode in a file called pandcpseudo.txt. 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 Part 2. This assignment is (very roughly) based on Programming Project 6.40 in Silbershatz. 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, Ptime and Ctime, that are described below). Each Producer thread should Enqueue X different numbers onto the queue (spin-waiting for Ptime cycles in between each call to Enqueue). Each Consumer thread should Dequeue P*X/C items from the queue (spin-waiting for Ctime 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, Enqueue, Dequeue). Use semaphores to describe synchronization logic in your pseudocode, and put all of the calls to P/V in the Enqueue/Dequeue implementations. Submit this pseudocode in a file called pandcpseudo.txt. 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!