Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Overview Your solution must be written in the C programming language. You must use fork and pipe to complete this project. Your program must

Problem Overview

Your solution must be written in the C programming language.

You must use fork and pipe to complete this project.

Your program must compile and run on the QBB244 lab computers using the gcc compiler.

This project creates processes to add all numbers in a file. The user will enter a number (1, 2, or 4) of parallel processes to create for processing the numbers. The system will then create this many processes, evenly dividing the file contents between the processes. For example, if the file has 1000 numbers and the user wants 4 processes, then each process would process 250 numbers in the file.You must test two ways for getting the data to the child processes:-

- Have the parent read the file and then send the appropriate numbers to the correspondingchild process using a pipe.

- Have the parent determine appropriate offsets in the file, send the offsets to the corresponding child process using a pipe, and have the child process read its portion of the file.

-In either of the above cases the child process(es) should return results to the parent process using a pipe.

III. System Description

The system is illustrated in the diagram shown below. The processes are as follows:

1.Parent process. This process allows the user to input the number of processes to create (1, 2, or 4). It determines what portion of the file each process must work on and informs the process via a pipe. More specifically, the first child process handles the first block in the file, and the second child process handles the second one and so on. The parent then waits for each child to report its result. Once each result is received, it combines the results and prints the overall result.

2. Child process. Receives which part of the file to process. Process the file and send results back to the parent process.

THERE ARE THERE FILE GIVEN: small.txt, medium.txt and large.txt

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

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions

Question

How much is $56 after an increase of 65%?

Answered: 1 week ago