CS 321 Spring 2012  >  Lecture Notes for Wednesday, February 1, 2012

CS 321 Spring 2012
Lecture Notes for Wednesday, February 1, 2012

Introduction to Processes (cont’d) [2.1]

Process States

There are generally many more processes available to be executed on a processor, than there are processors. Thus, such available processes will be in one of two states. They will be running—currently executing on a processor, or ready— available to be executed, but not currently executing, since some other process is begin executed. The process scheduler switches processes back & forth between these two, giving each available process some time on the processor. Some processes may get more time, because they have higher priority, but all should get some.

There may also be processes that are not available for execution, because they are waiting for something to happen. Such processes are blocked. A running process may become blocked because it is:

(A process can be suspended by another process, using one kind of signal; we will discuss this futher when we cover interprocess communication.)

A blocked process will be moved to a ready state when the event that it is waiting for, happens.

The diagram below illustrates how processes move between states.

Image not displayed: diagram of process states

Operating systems may divide process states somewhat more finely than the simple running/ready/blocked scheme we have described here.

Implementation of Processes

An OS kernel keeps track of all processes. We call the structure in which process information is stored, the process table. Each entry is a process control block. This contains all information needed to move a process into a running state.

Such a movement is called a context switch. The old process’s information is stored in its control block, the new process’s information is read from its control block, the registers are set up, and execution of the new process begins (or resumes).

In Linux, the process table is a doubly linked list. Each entry is of type task_struct. A task_struct contains:

CS 321 Spring 2012: Lecture Notes for Wednesday, February 1, 2012 / Updated: 3 Feb 2012 / Glenn G. Chappell / ggchappell@alaska.edu