next up previous
Next: CPU-bound vs. I/O bound Up: Assignment 5: Processor Scheduling Previous: Build a looper

Pit CPU-bound vs. CPU-bound

1.
If you start two processes at the same time, you expect each of them to get about half the CPU cycles. Test this hypothesis by running the following command: alarm 20 &; $\backslash$time loop 3. That will start alarm running in the background and then immediately start loop running (without waiting for alarm complete). Make sure that the alarm time is long enough that loop completes before alarm. What fraction of the CPU time did loop get? Run your programs several times to get an idea of how consistent your results are. If you can, run your programs while the machine is relatively idle. NOTE: You should definitely use $\backslash$time for this assignment; time does not seem to work correctly when it is on the command line with other commands.

2.
Now instead of starting the programs at the same time, introduce a delay between when you start alarm and when you start loop: alarm 10 &; sleep 1; $\backslash$time loop 3. Again, make sure loop has time to complete before alarm. As the delay increases, what happens to the percentage of the CPU that loop gets? What does this relationship tell you about the processor scheduling policy.

ANOTHER NOTE: Unfortunately, sleep only allows you to introduce delays that are at least a second long. To get intermediate values, you will have to be creative. One possibility is to put something else in place of the sleep statement, for example alarm 30 &; $\backslash$time ls; $\backslash$time loop 3. You can use the first $\backslash$time info to measure the delay and the second $\backslash$time info to measure the fraction of CPU time.


next up previous
Next: CPU-bound vs. I/O bound Up: Assignment 5: Processor Scheduling Previous: Build a looper
Allen B. Downey
3/17/1998