ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

C programming using pipes concept in UNIX

by | Nov 30, 2023 | questions

You will write a program that uses multiple processes to compute the sum of a set of (small) positive integers using pipes

There are two types of processes for this homework:

I). A set of “slaves” processes: Each slave process gets two small integers from itsargv, computes its sum and returns the result using the exit system call. So, a slave process is created for every sum.

II) A “master”process: This process is responsible for creating the slave processes, and coordinating the computation. Note that all the computation is done by the “slave” processes. All the numbers are provided in the command lineargv.Themasterprocess also set a timer at the start of computation to 3 seconds. If the computation has not been finished by this time, themaster processkills all the slaves and then exits. You should print an appropriate message(s) in this case. Note that themasterprocess may have to create multiple sets ofslaveprocesses. For example, if there are 8 numbers to be added, then themasterprocess will first create 4slavesand get the result from them. At this point there are 4 numbers, and it creates 2.

slaves. Finally one slave is created to compute the overall sum. To make it simpler, if the number of integers to add is odd, themasteradds a 0 to the list of numbers. This may happen at any step during the computation. The code formasterprocess should be compiled separately and its executable code should be calledmaster.The executable code for theslaveprocess should be calledslave. So, to compute the sum of the numbers 1 through 7, the command line will look like

master 1 2 3 4 5 6 7

Since the results are passed around byexitsystem call, keep the numbers small (single digit). Eachslaveprocess prints its process id, its operands, and their sum. Each time themastergets a result from a slave, it prints the pid of the slave and the partial sum.

Test your programs for the following cases:

master 1

master 1 2 3 4 5

master 1 2 3 4 5 6 7 8


ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!