Optional Homework -- Threads Programming

This is an optional homework for those people who did very poorly on Homework 1. If your grade is higher on this assignment, it will replace the current grade for Homework 1. You cannot use this to replace any other assignment. If you opt to do this one, it must be turned in by 4:00 PM Friday, May 5. There will be no extensions on it. (I want to leave a few days after Homework 5 is due, but finals are upon us.)

The assignment is to write a threaded simulator of a job scheduler. You have N CPUs, where N is a runtime parameter. You have M job sources; again, M is supplied at run-time. Each CPU and each job source is a separate thread; you may use as many more threads as you think you need. Job interrarrival time and total CPU time are uniformly randomly distributed pseudo-random numbers, but are integral.

The inputs, other than N and M, are the range of interarrival times and job times for each input source. Each one can be different.

The output is the mean completion time during the run. Limit the run time any way you choose; one good choice is some total number of jobs (also an input parameter in that case).

The scheduler is round-robin; each CPU should pull the appropriate job from the queue of those that have arrived, and let it "run" for some quantum. This is a discrete event simulator; you have some variable that represents the clock, and at each tick you increment it by the shortest interval pending.

As I said, you must use threading. Using locking and reentrancy as required.

Useful Resources

Apart from the usual man pages, you may find the following web sites useful: