Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your application is based on the Concurrency Guided Practice code and includes modifications to that code to support the creation of multiple producers and consumers,

Your application is based on the Concurrency Guided Practice code and includes modifications to that code to support the creation of multiple producers and consumers, which is more representative of a real-world scenario. Incorporate the following requirements into your application:

  • For all classes provide the following
    • Documentation at the top of the class file that includes
      • Your name
      • Date of development
      • Assignment (e.g., CIS317 Performance Assessment - Concurrency - Multiple Producers & Consumers)
      • Description of the class
  • Creat a C# project called yourname_pa_concurrency
  • Using the code from the concurrency guided practice, perform the following actions:
    • BlockingBuffer class
      • Modify the BlockingBuffer constructor to include an integer parameter that will represent the buffer (or collection) size
      • Use the parameter value as the size when creating the BlockingCollection object
      • Modify the BlockingPut and BlockingGet methods to include a name parameter, and incorporate that name into the output
    • Producer and Consumer classes
      • Add the following data members (private properties) to each class:
        • Name (string)
        • SleepTime (int)
        • StartProducing (int)
        • StopProducing (int)
      • Modify the constructor for each class to add parameters to set these properties
      • Modify the Run method in each class as follows:
        • the for loop should go from StartProducing to StopProducing
        • the sleep time should be SleepTime * 1000 instead of the hard-coded value
        • add the Name property as a parameter to the BlockingPut or BlockingGet call
        • add the Name property to the output string
  • The main application must be updated to do the following
    • Create the buffer with a size of 5
    • Create 3 producers as follows:
      • P1: start 10, stop 16, sleep 2
      • P2: start 25, stop 29, sleep 3
      • P3: start 30, stop 39, sleep 1
    • Create 2 consumers as follows:
      • C1: start 1, stop 9, sleep 3
      • C2: start 1, stop 13, sleep 2

Sample Output:

image
Your Name, Week 5 Concurrency PA - Multiple Producers & Consumers Producer P3 writes 30 Buffer cells occupied: 1 Consumer C2 reads 30 Buffer cells occupied: 0 Producer P3 writes 31 Buffer cells occupied: 1 Producer P1 writes 10 Buffer cells occupied: 2 Producer P3 writes 32 Buffer cells occupied: 3 Producer P2 writes 25 Buffer cells occupied: 4 Producer P3 writes 33 Buffer cells occupied: 5 Consumer C1 reads 31 Buffer cells occupied: 4 Producer P3 writes 34 Buffer cells occupied: 5 Consumer C1 reads 10 Buffer cells occupied: 4 Producer P3 writes 35 Buffer cells occupied: 5 Consumer C1 reads 32 Buffer cells occupied: 4 Consumer C2 reads Buffer cells occupied: 3 Producer P1 writes 11 Buffer cells occupied: 4 Producer P3 writes 36 Buffer cells occupied: 5 Consumer C1 reads 33 Buffer cells occupied: 4 Producer P3 writes 37 Buffer cells occupied: 5 Producer P2 writes 26 Buffer cells occupied: 5 Consumer C2 reads 34 Buffer cells occupied: 5 Consumer C1 reads 35 Buffer cells occupied: 4 Producer P1 writes 12 Buffer cells occupied: 5 Consumer C2 reads 11 Buffer cells occupied: 4 Producer P3 writes 38 Buffer cells occupied: 5 Consumer C2 reads 36 Buffer cells occupied: 4 Producer P3 writes 39 Buffer cells occupied: 5 Producer P3 done producing Terminating Producer Consumer C1 reads 37 Buffer cells occupied: 4 Producer P1 writes 13 Buffer cells occupied: 5 Consumer C2 reads 26 Buffer cells occupied: 5 Producer P2 writes 27 Buffer cells occupied: 5 Consumer C2 reads 12 Buffer cells occupied: 4 Producer P1 writes 14 Buffer cells occupied: 5 Consumer C2 reads 38 Buffer cells occupied: 4 Consumer C1 reads 39 Buffer cells occupied: 3 Consumer C2 reads 13 Buffer cells occupied: 2 Consumer C1 reads 27 Buffer cells occupied: 1 Producer P1 writes 15 Buffer cells occupied: 2 Producer P2 writes 28 Buffer cells occupied: 3 Consumer C2 reads 14 Buffer cells occupied: 2 Consumer C2 reads 15 Buffer cells occupied: 1 Consumer C2 reads 28 Buffer cells occupied: 0 Producer P1 writes 16 Buffer cells occupied: 1 Producer P1 done producing Terminating Producer Consumer C1 reads 16 Buffer cells occupied: 0 Consumer C1 read values totaling 260 Terminating Consumer Producer P2 writes 29 Buffer cells occupied: 1 Producer P2 done producing Terminating Producer Consumer C2 reads 29 Buffer cells occupied: 0 Consumer C2 read values totaling 311 Terminating Consumer

Your Name, Week 5 Concurrrency PA - Multiple Producers & Consumers Buffer cells occupied: 1 Buffer cells occupied: 0 Buffer cells occupied: 1 Buffer cells occupied: 2 Buffer cells occupied: 3 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 3 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 5 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Producer P3 writes 30 Consumer C2 reads 30 Producer P3 writes 31 Producer P1 writes 10 Producer P3 writes 32 Producer P2 writes 25 Producer P3 writes 33 Consumer C1 reads 31 Producer P3 writes 34 Consumer C1 reads 10 Producer P3 writes 35 Consumer C1 reads 32 Consumer C2 reads 25 Producer P1 writes 11 Producer P3 writes 36 Consumer C1 reads 33 Producer P3 writes 37 Producer P2 writes 26 Consumer C2 reads 34 Consumer C1 reads 35 Producer P1 writes 12 Consumer C2 reads 11 Producer P3 writes 38 Consumer C2 reads 36 Producer P3 writes 39 Producer P3 done producing Terminating Producer Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 5 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 5 Buffer cells occupied: 4 Buffer cells occupied: 3 Buffer cells occupied: 2 Buffer cells occupied: 1 Buffer cells occupied: 2 Buffer cells occupied: 3 Buffer cells occupied: 2 Buffer cells occupied: 1 Buffer cells occupied: 0 Buffer cells occupied: 1 Consumer C1 reads 37 Producer P1 writes 13 Consumer C2 reads 26 Producer P2 writes 27 Consumer C2 reads 12 Producer P1 writes 14 Consumer C2 reads 38 Consumer C1 reads 39 Consumer C2 reads 13 Consumer C1 reads 27 Producer P1 writes 15 Producer P2 writes 28 Consumer C2 reads Consumer C2 reads 15 Consumer C2 reads 28 Producer P1 writes 16 Producer P1 done producing Terminating Producer Consumer C1 reads 16 Buffer cells occupied: 0 Consumer C1 read values totaling 260 Terminating Consumer Producer P2 writes 29 Buffer cells occupied: 1 Producer P2 done producing Terminating Producer Consumer C2 reads 29 Buffer cells occupied: 0 Consumer C2 read values totaling 311 Terminating Consumer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Technology Control And Audit

Authors: Angel R. Otero

5th Edition

1498752284, 9781498752282

More Books

Students also viewed these Programming questions

Question

What is the work environment like? Friendly/collegial?

Answered: 1 week ago

Question

Define risk and risk assessment.

Answered: 1 week ago