The purpose of this research project is to explore the utility of task delegation with forking and threading.
Your report has to cover the general purpose of forking and threading an application. Pay particular attention to heavy process vs. light-weight process designation. What role do these tools play in parallelism? How do they interact with the library tools exec* and exit?
The support code will recreate the wc command which counts words, lines, and characters as well as giving a total when applied over multiple files. You'll need to take command-line arguments for this task. These were covered in section 6.14 of your C book. Your command line arguments need only be file names whose character, word, and line counts your user desires.
There will be three versions of this code, however:
Monolithic: Create a single program that does all the operations itself.
forked: Create a program that uses fork to calculate the individual counts for each file in a separate child. You'll still need to print the totals in each count category for all files in the parent process.
Threaded: Create a program that creates a separate thread to calculate the individual counts for each file. Again, you'll be printing the totals for each count category back in the original thread.
You can find some information on forking in your C book in Chapter 12. There are also many fine web resources such as this one.
Your books, unfortunately, have no information on threading. To find out more about this aspect of the project, you can see many fine pages like this one or this one.
I've also found excellent introductory materials in Understanding Unix/Linux Programming: A Guide to Theory and Practice by Bruce Molay (ISBN: 0-13-008396-8; © 2003 Prentice Hall). Chapter 8 has introductory forking and Chapter 10 has intermediate fork operations. Chapter 14 has lots of great information on threading as well!
The best reference of all for fork, however, is Advanced Programming in the UNIX Environment by W. Richard Stevens (ISBN: 0-201-56317-7; © 1992 Addison-Wesley Publishing). It has lots of detailed information on the fork tool spread nearly throughout its 744 pages. (But oddly no threading...*sniff*)
This assignment is (Level 5). (This does not include any enhancements or add-ons you chose to do below, please add their appropriate level as well.)
It is a shame that the Advanced Programming... book didn't have threading information. I wonder why that is? For an additional (Level 2) investigate the history of forking and threading and report on them as well.
For a brief time there was another alternative to fork called vfork. For an additional (Level 2) investigate the origins and purpose of vfork and report on it. (Of course, once a 'standard', always available, right? *sigh*)
In fact, if you implement your sample code in a fourth version utilizing vfork I'll give you another (Level 2) — but you must take full advantage of the peculiarities of vfork to get these full levels. A half-hearted implementation that just mimics the fork version will only earn (Level 0.5)!