Vous êtes sur la page 1sur 3

J.E.D.I.

1 Process Concept
1.1

Objectives

This chapter introduces the idea of processes. In particular, we will discuss the definition of
processes and the life cycle of a process.

1.2

Chapter Outline

This chapter is divided into the following sections

Process Concept

Process Life Cycle

Process Control Block

1.3

Process Concept

A process can be defined as a program in execution. When a programs is created, it exists


merely as instructions in a file until they are run by the CPU. When a program is run, the
instructions are loaded into main memory and thus becomes a process. In addition, you can
load a single copy of your program multiple times in memory. Even though the processes are
all executing the same instructions, they are executing independently of each other and are
therefore different processes.
However, a process is more than just the execution of your program's instructions. It also
should contain a pointer to the currently running instruction, space in memory allocated for the
program's data, and a list of operating system resources (such as files) that the process is
currently using.
In the early days of computers, computers would only have a single process running with all
CPU resources allocated to that single process. With the advent of multiprogrammed batch
systems, operating systems would have multiple processes from possibly multiple users all
running concurrently. Thus an operating system should establish controls on how these
processes interact with one another and with the operating system. The OS should be able to
address issues such as:

Interprocess Communication - should processes be able to influence each other's


execution? What should a process do to communicate with another process?

CPU Scheduling - when and which process will be given CPU time, as the CPU can only
execute instructions from once process at a time

Resource Allocation - what resources are allocated to processes and when? For
example, what if two processes decide to use the printer at the same time?

Process Synchronization - what if concurrently running processes must execute in a


certain specific order? For example, what if proper execution of two processes
mandates that process 1 should always write to a file before process 2 reads it? What if
a process must not be removed from CPU due to a critical operation?

Deadlock issue what if two or more processes are waiting for each other to finish and
thus they never do. How should the OS handle this?

These issues are fundamental to any operating system. We will discuss these issues over the
span of the next few chapters.
Operating Systems

J.E.D.I.

1.4

Process Life Cycle

A process undergoes the following life cycle during the course of its execution

New: The newly created process is loaded into memory

Ready: The process is ready for execution. It waits in the ready queue until it is given
CPU time.

Running: The processes is running on the CPU, currently executing program instructions

Waiting: The process is waiting for I/O.

Terminated: The process has finished execution and is waiting for the OS to deallocate
it from memory and to clear any used resources.

Process Life Cycle


Processes that are ready to execute (in the ready state) are placed in the ready queue. Only a
single process can run on a single processor at a given time. It is up to the CPU scheduler to
choose between processes in the ready queue that will run next on the CPU. The CPU
scheduler may also pre-empt or force a process in the running state to go back to the ready
state in order to execute another process, for example, a process with a higher priority than
the currently executing process.
A process undergoes a CPU-I/O burst cycle. A process on a CPU burst is currently executing
instructions. At some point in time, it stops to wait for I/O to and from the user, ending its CPU
burst phase and entering the I/O burst phase. Processes alternate between executing
instructions and waiting for additional input or sending output to the user.
When an I/O burst happens, the process is moved from the running state into the waiting
state. I/O is often an order of magnitude slower than CPU execution. Rather than letting the
CPU go idle for a long period of time, the CPU scheduler sends processes in the I/O burst into
Operating Systems

J.E.D.I.

the waiting state. This allows for other processes in the ready queue to run their own CPU
burst, making sure that the CPU is not kept idle as much as possible. After a process has
finished with its I/O burst, it is sent back into the ready queue.

1.5

Process Control Block

The process control block is a data structure in the operating system which is used to describe
a process. Mostly, process control blocks contain the following information:

Process identifier usually a number to indicate what process this process control block
refers to.

Register values as a program executes, it changes values in the CPU's registers. The
register values store the current CPU register values

Program counter although this is a register value as well, we give this a special
mention. The program counter indicates the currently executing instruction of the
process.

Address space indicates the space in memory the process is currently allocated.

Process accounting information this includes process priority, the amount of time used
by the process in the CPU, or any additional information needed by the OS

I/O status information list of files or devices being used by the process.

When a process is moved from the running state to the waiting or ready state, the CPU must
perform what is called a context switch. In loading a different process into the CPU for
execution, it must know what the register values are of the entering process, what space in
memory the process resides in, what instruction next to execute, etc. Basically, the OS needs
the complete state of the process so that it will know where to start execution from. This
information is what is stored in that process' PCB.
Of course the exiting process information must also be stored in its PCB so that the CPU will
know where it left off when that process returns to the running state.

Context switch diagram

Operating Systems

Vous aimerez peut-être aussi