CS 444 hw5 Pre-emptive Scheduler 1) You will need to set and run the system timer, the "PIT". An example of how to do this is in $pcex/timetest.c. The timer (or "clock") in timetest.c will take up to approximately 55 milliseconds to run down and cause an interrupt. Change it to interrupt every 10 ms, like Linux. When you first fold this in, it will print a "." for every tick--leave that in for a while, to make sure it's ticking away, but take out the dots before the final testing. 2) Add a CPU quantum to each process. Decrement it in the tick handler and call schedule when it's gone. You should confirm that when there are two cpu bound processes, they alternate in execution. The preemptions of user processes are recorded in the debug_log and printed out at the end of the run along with the marks for input, output, and process-switch from zombie. 3) Keep counts of how much cpu each uprog uses and how many characters each outputs. To do this add appropriate fields to the proc structure. At each tick increment the cpu field of the running process. Also, each time there is a successful enqueue, increment the output character count. Print the counts when the whole program exits (that is, when you print the exit values). There may be new race conditions in the kernel due to preemption in the kernel. For example, "number_of_zombie++" in sysexit needs protection unless we can prove it is implemented with just one instruction. Otherwise, between the two, there could be a preemtion causing another process to run and exit, reading the old count. They both end up writing the same count, losing one increment. This is called the lost update problem. Most of the ++'s are acting on local variables-- these are process-private and thus immune from such shared access. Testing: all scripts should show debuglog output. 1. Using the same programs as in hw3, now all in uprog123.c, confirm that now process 1 is preempted during its big idle loop. The scheduler as provided will debug_log "|(1-2)" or "|(1-3)" to mark this preemption. Make sure your quantum is large enough to give a process at least 40 ms of CPU, but no more than 100ms. Make a script of a run showing this preemption in uprog.script. This script may have tick reports as well if you want (see next paragraph.) 2. There are two cpu intensive program in this directory to use in place of two of the uprogs of hw3. This pair of programs, plus the old uprog1 is in seqtest.c. You should see the two programs get roughly equal shares of the cpu, while the program with output is also able to run. Add debug reports such as "*2" for a tick (while process 2 is running) to the debug_log. Then it will be obvious how many ticks each process gets to run. Make a script of this run in seqtest.script. 3. Add the other instrumentation specified above, and make runs with the statistical summary at the end, in uprog.stats and seqtest.stats. Note: all new fields to the proc structure should be placed at the end, to ensure that asmswtch will still work properly.