Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Program Assignment: Pipelined Tasks

Write a program with a concurrent pipeline architecture that has three steps: 1) threads that produce 1000 random integers, 2) threads that filter out multiples of 3 from the integers produced in step 1, and 3) threads that groups the integers from step 2 into one of 10 files, as explained below. (See the figure after the next paragraph.) The first two steps are similar to what is in wait5.cpp. Place everything in a class named Pipeline, making sure that items related to thread communication are static members.

For the third step, create exactly 10 threads that retrieve integers from the second queue populated by the threads in Step 2, and group the numbers by their modulus (remainder) base 10. Each of these 10 "grouper" threads will only remove a number from the front of the queue if its modulus corresponds to theirs. For example, grouper thread 0 will check to see if the first number in the queue ends in a 0 (i.e., it is congruent to 0 (mod 10)). If so, it will remove it from the queue and write it to its file (see below). Otherwise it does nothing. If the number at the front of the queue does not end with the proper digit, the thread leaves it in the queue for the appropriate thread to process. Each grouper thread does likewise for its respective remainder mod 10. The following diagram represents the architecture of this program.

589_Architecture-Diagram.jpg

When you are done, print out a report like the following (your numbers will vary):

Group 7 has 271 numbers Group 1 has 244 numbers Group 9 has 264 numbers Group 4 has 278 numbers Group 0 has 275 numbers Group 5 has 267 numbers Group 8 has 285 numbers Group 3 has 279 numbers Group 2 has 268 numbers Group 6 has 242 numbers

Note that the order of the group reports varies on the order that the grouper threads terminate. Use 4 producer threads and 3 filter threads.

Collect your 10 output text files and your source code, along with the execution output like what you see above, into a zip file for submission.

Note: my solution to this program runs on all platforms, but it is HORRIBLY SLOW (wait 2 minutes, but it works) on Visual Studio 2015. It runs instantaneously on clang, g++, MinGW, and Visual Studio 13.

FYI, my program is 91 lines of actual code, much of which is copied from/based on wait5.cpp.

Attachment:- Wait.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92790098

Have any Question?


Related Questions in Computer Engineering

Scenarioyour friend tim hall is an expert in creating

Scenario Your friend, Tim Hall, is an expert in creating websites. In Hall's opinion, creation of websites is now a simple task using tools such as Adobe Dreamweaver, and therefore, he does not feel the need to learn HTM ...

Suppose a bowl has 9 chips one chip is labeled 1 three

Suppose a bowl has 9 chips. One chip is labeled "1", three chips are labeled "3", and five chips are labeled "5". Suppose two chips are selected at random with replacement. Let the random variable X equal the absolute di ...

Question suppose we have a rectangle class that includes

Question : Suppose we have a Rectangle class that includes length and width attributes of type int, both set by the constructor. Create a compareTo method for this class so that rectangle objects are ordered based on the ...

You have a senior project you have to write 20 page long

You have a senior project You have to write 20 page long pages. You also have to make a project on a card explain what i m talkiing about. it should CIS program so utilize thre SDLC project management, databases, coding, ...

Question write 1 page that respond to the following

Question: Write 1 Page that respond to the following questions with your thoughts, ideas, and comments. This will be the foundation for future discussions by your classmates. Be substantive and clear, and use examples to ...

1 under what circumstances is it advantageous for a company

1. Under what circumstances is it advantageous for a company competing in foreign markets to concentrate its value chain activities in a select few locations? Under what circumstances is it advantageous for a company com ...

Describe the definition of ransomware and what is wannacry

Describe the definition of ransomware. And what is wannacry threat?

Can someone help me with this question you need step by

Can someone help me with this question? You need step by step and You need names of any theorms or formulas you are using please. The Codechef Programming Society has 198 membership-paying mem- bers, 97 females and 101 m ...

A sequence of natural numbers a1 a2 an is said to be a

A sequence of natural numbers (a 1 , a 2 , ..., a n ) is said to be a degree sequence if there exists an undirected graph on n vertices {v 1 , v 2 , ..., v n } such that the degree of v i  is a i  for each i = 1, 2, ..., ...

Question is it ethical for a potential employer to use the

Question: Is it ethical for a potential employer to use the Internet this way? Is it legal? What if an angry ex-boyfriend or ex-girlfriend posted some things, pretending to be you? How might this affect your chances for ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As