Comp111: Operating Systems
Classroom Exercise 1: Time
Fall 2017

group member 1: ____________________________ login: ______________
group member 2: ____________________________ login: ______________
group member 3: ____________________________ login: ______________
group member 4: ____________________________ login: ______________
group member 5: ____________________________ login: ______________
group member 6: ____________________________ login: ______________
group member 7: ____________________________ login: ______________
group member 8: ____________________________ login: ______________

In class we have discussed a bit about how time is parceled out to processes. Let's go a bit deeper. In a typical linux instance, the amount of time that a process takes is measured by sampling every 1/100 of a second and counting that 1/100 of a second as being used by the process that is currently running when the sample is made. If a context switch is occurring, the time is counted toward the operating system itself, instead. The following (oversimplified) time-space diagram depicts processes and context switches, as well as the times at which the operating system measures state. Time is depicted on the horizontal axis and process on the vertical axis. The states of the processes P1, P2, and P3 are checked at the times at which the vertical dotted lines appear. The time between lines represents 1/100 second.

  1. In the time-space diagram, how much time is recorded as being used by processes P1, P2, P3?

  2. According to your best visual estimates, how much time is actually consumed by each process P1, P2, P3?

  3. The efficiency of an operating system is the percentage of time spent in doing useful work, relative to total time available. According to your best visual estimates, what is the actual efficiency of the operating system in the above diagram?
  4. Why is the sum of all system and user time for a single core machine always less than elapsed wallclock time?

  5. What is the relationship between user time, system time, and wallclock time for a multi-core computer that can run two or more processes concurrently?

  6. (Advanced) Suppose that you are trying to do the above calculations and the times between samples are not equal, as they are in the diagram above. How would you change your algorithm to calculate efficiency?

  7. (Advanced) A "real-time operating system" is one in which one can be assured that responses to external events will occur very close in time to when the events occur. It is often claimed that "linux is not a real time operating system". Based upon your knowledge of the scheduler so far, what impedes "real-time" response?