Professional Documents
Culture Documents
Operating
Systems
PART TWO: PROCESS MANAGEMENT:
Lecture5: Introduction to Processes:
Lecture 5:
Scope:
Introduction to processes.
Process implementation.
Operations on processes
Goals:
Define a process
Examine how processes are implemented in the
computer system.
Understand the role of the operating system in
process management.
2
Introduction:
A process can be thought of as a program in
execution.
A process will need certain resources to accomplish
its tasks: such as
CPU time, Memory, Files and I/O devices
A process is the unit of work in most systems such
systems consist of a collection of processes:
o/s processes execute system code.
User processes execute user code.
All these processes can potentially execute
concurrently.
3
Introduction2
Modern computers do multitasking
While executing a program, a computer can also read
from a disk and output text to a screen or a printer.
CPU switches from one process to another
At any one instance, the CPU runs only one program
In the course of one second CPU may work on several
programs, thus giving the users the illusion of
parallelism (pseudo-parallelism).
This is in contrast to h/w parallelism of multiprocessor
systems
4
Introduction3
A process is more than the program code:
A program is a passive entity.
A process is an active entity with a program counter
specifying the next instruction to execute and a set of
associated resources.
A process also includes:
The current activity, as represented by the value of the
program counter and the contents of the processors
registers.
The process stack containing temporary data, such as
subroutine parameters, return addresses and temporary
variables.
A data section containing global variables.
5
Introduction4
6
Process states:
As a process executes, it changes state.
The state of a process is defined partly by the
current activity of that process
New the process is being created.
Running instructions are being executed.
Waiting the process is waiting for some event to
occur.
Ready the process is waiting to be assigned to
the processor.
Terminated the process has finished execution.
7
Process states
Running
Terminated
2 New
1
3
Blocked Ready
8
Introductionprocess states:
Transition 1 occurs when a process discovers that it
cannot continue (can happen automatically or through
system call)
Note: Transitions 2 and 3 are caused by process
scheduler, which is a part of the O/S.
Transition 2 occurs when the scheduler decides that
running process has had enough CPU time.
Transition 3 occurs when other processes have had their
share of the CPU and it is time for the first process to get
the CPU again.
Transition 4 occurs when the external event for which a
process was waiting (for example, arrival of input)
happens.
9
Process implementation:
O/S maintains a process table or the Process
Control Block (PCB) to implement, the process
model with one entry per process.
It contains information about the process state,
including:
Program counter,
Stack pointer,
Memory allocation,
Status of its open files,
Accounting information, etc.
This is necessary when the process is switched from
running to ready state so that it can be restarted later
as if it had never been stopped.
10
Process implementation
Pointer Processstate
Processnumber(id)
Programcounter
Registers
Memorylimits
Listofopenfiles
11
Process Implementation
13
Operations on
Processes:
Operating Systems that support the process concept
must provide some way to create all the processes
needed.
In some Operating Systems it is possible to have processes
present when the system comes up.
In other Operating Systems, some way is needed to create
and destroy processes as the need arises.
Processes need a way of creating other processes.
Each process has one parent, but can have zero, or
more children.
14
Process creation and
termination:
A process is an independent entity, though often it
need to interact with other processes.
One process may generate some output that another
process would use as input.
For example, in the shell command:
cat chapter1 chapter2 chapter3 | grep
tree
The process, running cat, concatenates and outputs
three files.
Second process, grep, selects lines with the word
tree.
Due to differences in speed grep may be ready to
run, but no input . It must block until input is available.
15
Process Creation and
Termination
Four Principal events that cause
process creation are:
System initialization
Execution of a process creation system
16
Process Creation and
Termination
Four Conditions that lead to process
termination:
Normal exit (voluntary)
Error exit (voluntary)
17
Next lecture:
Process scheduling.
Cooperating processes.
Threads.
IPC.
18