I have an application where a bit of parallel processing would be of benefit. For the purposes of the discussion, let’s say there is a directory with 10 text files in it, and I want to start a program, that forks off 10 processes, each taking one of the files, and uppercasing the contents of the file. I acknowledge that the parent program can wait for the children to complete using one of the wait functions, or using the select function.
What I would like to do is have the parent process monitor the progress of each forked process, and display something like a progress bar as the processes run.
My Question.
What would be a reasonable alternatives do I have for the forked processes to communicate this information back to the parent? What IPC techniques would be reasonable to use?
In this kind of situation where you only want to monitor the progress, the easiest alternative is to use shared memory. Every process updates it progress value (e.g. an integer) on a shared memory block, and the master process reads the block regularly. Basically, you don’t need any locking in this scheme. Also, it is a ‘polling’ style application because the master can read the information whenever it wants, so you do not need any event processing for handling the progress data.