Purchase Solution

Computer Science: Fork Function

Not what you're looking for?

Ask Custom Question

Write a C program that takes an integer argument from the command line and outputs the sum of all digits of the integer. For example, the result of the invocation sum of digits 12345 should be 15.

The program has two constraints:

1) Each process can do at most one addition. If you want to calculate the sum of more than two digits, you will have to fork one or more processes in order to do that, and each of the forked processes in turn can process at most one more addition before forking further more process(es) to compute the sum.

2) Each process can fork at most one other process.

Purchase this Solution

Solution Summary

GNU C compiler (gcc) version 4.3.4 was used during the development of attached program is in the attached Excel file. It also prints information messages indicating what addition is being performed by which process.

Solution Preview

Please find attached an implementation (525108.c) to achieve the goal. Please be aware that this is not the only way to go about it, that is, many approaches are possible in this case.

Attached program has been tested for ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.