Intro to Computer Systems

Chapter 12: System Integration

Process Management

In this section we consider how the Operating System coordinates the execution of different software units (processes) and we explore in more detail the notion of a process.

The Concept of a Process

It is very important to distinguish between a program and the activity of executing a program. The former is the static set of instructions to be executed, whereas the latter is the action of executing a program, and as such it is dynamic and changing. The activity of executing a program is known as a process. For example, a word processor is a program, but many people may be using the same word processor program at the same time, each running their own process. The current status of a process is called the process state. This is information that includes the owner of the process - the user executing the process - the current position in the program being executed, open files, memory locations allocated to the user, and so on.

In a typical computer many processes are normally competing for the computer resources. It is the task of the Operating System to manage this so that each process has the resources that it needs, that independent processes do not interfere with one another, that their execution and data are protected, and that processes can exchange information when required. This has to be also very efficient, to be able to manage all the users and system requests at the same time.

Process Administration

The coordination of process executions is handled by the scheduler and dispatcher within the Operating System. The scheduler maintains a record of the processes present in the computer, introduces new processes to this pool, and removes completed pro­cesses from this pool. Processes are maintained by the scheduler in a waiting queue, in a certain priority order. Processes priorities change during their execution to ensure that they all get to run on the CPU. The dispatcher selects the process from the waiting queue and allocates the CPU to that process.

To keep track of all processes, the scheduler maintains a block of information in main memory called process table. Each time the execution of a process is requested, the scheduler creates a new entry for that process in the process table.

Multiprogramming between process A and process B
Multiprogramming between process A and process B

In time-sharing/multitasking are based on multiprocessing, that is, dividing time into short segments, each called a time slice, and then switching the CPU’s attention among processes. Each is allowed to execute for one time slice (as in the figure above). The procedure of changing from one process to another called a process switch (or a context switch).

Each time the dispatcher picks a process for the queue and runs it, it initiates a timer that will indicate the end of the slice by generating a signal called an interrupt. When the CPU receives this interrupt signal, it completes the current machine cycle, saves all current process information - where in the program it was executing, contents of registers, open files, etc - and begins executing a specific program called an (interrupt handler). This program constitutes the Operating System response to the interrupt signal.

Thus, the effect of the interrupt signal is to preempt the current process from the CPU and transfer control back to the dispatcher. At this point, the dispatcher selects another process from the queue, re-starts the timer, and allows the selected process to begin its time slice.

The use of interrupts for terminating time slices is only one of many applications. There are many situations in which an interrupt signal is generated, each with its own interrupt routine.

For example, both clicking a mouse and pressing a key on the keyboard generate interrupt signals that cause the CPU to set aside the current activity and handle the interrupt.

Competition among Processes

An important task of the Operating System is the allocation of resources to processes. For example:

This allocation task may appear simple at first glance, but below the surface there are several details that can lead to failure if the system is not designed carefully. There are many processes competing for the same resources, and there needs to be a way of prioritising them.