Performance Metrics Scheduling Processes and Threads

Another example is possible interference with real-time tasks, such as viewing a movie or burning a CD. Complexity: a multitasking operating system has to deal with issues of synchro- nization and resource allocation Chapter 4. If the different processes belong to different users, the system also needs to take care of security this has been the standard in Unix since the 1970s, but supporting multiple users at once still doesn’t exist on Windows desktop systems. However, on the bottom line, the benefits of multiprogramming generally far outweigh the costs, and it is used on practically all systems.

3.3 Scheduling Processes and Threads

The previous section argued that time slicing should be used. But which process 1 should be executed at each moment? This question, which relates to the processes that are ready to run and are loaded into memory, is called short-term scheduling. The action of loading the process state into the CPU is known as dispatching.

3.3.1 Performance Metrics

Performance depends on how you measure it The decision about which process to schedule might depend on what you are trying to achieve. There are several possible metrics that the system could try to optimize, including Response time or turnaround time — the average time from submitting a job un- til it terminates. This is the sum of the time spent waiting in the queue, and the time actually running: T resp = T wait + T run ✲ time ❄ job arrives ❄ starts running ❄ job terminates ✛ ✲ T wait waits in queue ✛ ✲ T run running ✛ ✲ T resp If jobs terminate faster, users will be happier. Note: Interactivity, response, and termination Many interactive applications are reactive, just like the operating system; for ex- ample, a text editor spends most of its time waiting for user input, and when it gets some, it quickly handles it and returns to wait for more. Thus the notion that a job is submitted, waits, runs, and terminates seems to be irrelevant for such applications. 1 Whenever we say process here, we typically also mean thread, if the system is thread based. 65 However, we can ignore the fact that we have one continuous application running, and regard the handling of each input as a distinct job. Thus when the user hits “enter” or some other key, he is submitting a job, which waits, runs, produces a response, and terminates or at least, becomes dormant. The time to termination is then actually the time to produce a response to the user input, which is the right metric. In essence, the model is that the application does not compute continuously, but rather performs a sequence of “CPU bursts”, interspersed by IO activity and specifically, terminal IO waiting for user input. In the past, many textbooks made a distinction between turnaround time which was the time till the whole application terminated, and response time which was the time until it produced its first response. This is based on a model of an application that computes continuously, and generates many outputs along the way, which does not seem to correspond to the way that any real applications work. Variants on this idea are Wait time — reducing the time a job waits until it runs also reduces its re- sponse time. As the system has direct control over the waiting time, but lit- tle control over the actual run time, it should focus on the wait time T wait . Response ratio or slowdown — the ratio of the response time to the actual run time: slowdown = T resp T run This normalizes all jobs to the same scale: long jobs can wait more, and don’t count more than short ones. In real systems the definitions are a bit more complicated. For example, when time slicing is used, the runtime is the sum of all the times that the job runs, and the waiting time is all the times it waits in the ready queue — but probably not the times it is waiting for an IO operation to complete. Throughput — the number of jobs completed in a unit of time. If there are more jobs completed, there should be more happy users. Utilization — the average percentage of the hardware or the CPU that is actually used. If the utilization is high, you are getting more value for the money invested in buying the computer. Exercise 52 The response time can be any positive number. What are the numerical ranges for the other metrics? When are high values better, and when are low values better? Other desirable properties are predictability and fairness. While it is harder to quantify these properties, they seem to correlate with low variability in the service to different jobs. 66 The chosen metric should be one that reflects the scheduler’s performance Not all metrics are equally applicable. For example, in many real-world situations, users submit jobs according to their needs. The ratio of the requirements of all the jobs to the available resources of the system then determines the utilization, and does not directly reflect the scheduler’s performance. There is only an indirect effect: a bad scheduler will discourage users from submitting more jobs, so the utilization will drop. In a nutshell, utilization and throughput are more directly linked to the workload imposed by users than to the scheduler. They become important when the system is overloaded. Metrics related to response time are generally better for the evaluation of schedulers, especially in an interactive setting.

3.3.2 Handling a Given Set of Jobs