Explore BrainMass

Computer Science: Fork Function

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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.

© BrainMass Inc. brainmass.com October 25, 2018, 8:05 am ad1c9bdddf

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 ...

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.

See Also This Related BrainMass Solution

IBM's corporate strategy for the 21st century; what does 'Beyond the Blue' mean?

See the attached case file.

1) What is IBM's corporate or multibusiness strategy for the 21st century, and how is it different from its long-standing strategy?

2) What does the case title, "Beyond Blue" mean?

These question stem from the article attached. "Beyond Blue".

View Full Posting Details