CS 302 - Programming Assignment 5

This assignment is about concurrent (non-cooperating) processes and threads and it makes use of the files contained in this zip file.

In the zip file there are the outlines of five C programs, serialWorker.c, processWorker-parent.c, processWorker-child-io.c, processWorker-child-calc.c, and threadWorker.c. Also in the zip file is a data file called shaks12.txt and a batch file called createDataFiles.bat that uses shaks12.txt to create ten new data files called data0.txt through data9.txt.

The C programs are meant to simulate the workload that a server program might have. The "workload" that these programs are supposed to handle is copying input files to output files (I/O bound tasks) and doing long calculations (CPU bound tasks). The goal of the assignment is to implement and study three different strategies for doing a lot tasks as quickly as possible.

The first program is serialWorker.c and it is supposed to implement the simplest strategy for doing a number of tasks. The strategy is to do one task at a time. As explained in the file serialWorker.c, the program is supposed to randomly choose input files and copy them, one after another, and also do randomized calculations.

The second program is made up of the three files processWorker-parent.c, processWorker-child-io.c, and processWorker-child-calc.c. Together, these files are supposed to implement a strategy of creating a separate worker process to do each (I/O or compute) task. The file processWorker-parent.c will be the (master) process that creates the worker processes, and processWorker-child-io.c and processWorker-child-calc.c are the programs that each worker process is instantiated from. The hope here is that many worker processes can run at the same time, thereby accomplishing the work tasks in less time than the serial task strategy. In other words, this is a way of "parallelizing" the serial task strategy.

The last program, threadWorker.c, parallelizes the tasks by creating multiple threads, one thread for each input file that needs to be copied and one thread for each compute task.

Follow the directions in each of the five C files and implement these three task strategies. When your programs are completed, try them on small, medium, and large runs of tasks. A medium run of tasks should have about 100 tasks. Try to have large runs with several hundred tasks (but don't run such large numbers of tasks with the serial strategy). How do the strategies perform? Which strategy is fastest? How do processes and threads scale to large numbers of tasks (does one scale better than the other)? Does the data you collect from doing several runs of these programs agree with what you were expecting?

Turn in a zip file containing your versions of the five C programs and an explanation of what you found when you ran the three different strategies. (Please do not send back to me the output files generated by the programs or the data files created by the batch file.)

This assignment is due Friday, March 9.


Return to the main homework page.
Return to the CS 302 home page.


compliments and criticisms