Introduction
Warning
This portion of the book is under construction, not ready to be read
6. Introduction#
We are going to discuss the various methods used by the operating system to allow multiple programs to execute on a computer while giving each the illusion it has the entire computer to itself. But before we get to discussing scheduling algorithms, we need to define a few terms we will use in that discussion. The terms program and process are often used inter-changeably, but we will distinguish them and only use them according to our individual definitions. Recall when we discussed abstracting hardware Abstracting Hardware, we drew the distinction between the contents of the executable stored on disk (the program) from an execution of those contents (a process). In this chapter we will briefly introduce the problem solved by scheduling and then dive into how it happens.
Consider a very simple computer with a single processor and some memory. If we have a single user who only wants to run a single instance of a program on that processor, we are able to meet the user’s need. However, this model isn’t very useful because if we introduce a second user or a second task, we need a way to ensure that all users can run the processes they need. Without help from an operating system, the users would have to coordinate time for using this computer. This coordination gives users good control over when their process runs, but does not handle conflicts or changes well. What if the user scheduled to use the computer misses their appointment? The hardware is left idle and that user’s process still needs to run.
As with other resources managed by an operating system, we solve the scheduling problem by virtualizing the processor or CPU. As with memory, this virtualization of the resource allows the operating system to provide the illusion of an infinite number of CPUs on which a process can run.
For the remainder of this chapter we will discuss what a process is and how we can virtualize the CPU. Next we will look at threads and how they differ from a process. Finally, we will end with a look at the methods for scheduling processes or threads.