Processes
Processes
K.S.SENDHIL KUMAR
Agenda
Process Concept
Process Model
Process Hierarchy
Process – a program in execution; process execution must progress
in sequential fashion
A process includes:
program counter
stack
data section
Multiple parts
The program code, also called text section
Current activity including program counter, processor registers
Stack containing temporary data
Function parameters, return addresses, local variables
Data section containing global variables
Heap containing memory dynamically allocated during run time
Program is passive entity, process is active
Program becomes process when executable file loaded
into memory
Execution of program started via GUI mouse clicks,
command line entry of its name, etc
One program can be several processes
Consider multiple users executing the same program
The process model
Single PC Multiple PCs Multiprogramming of four
(CPU’s point of view) (process point of view) programs
Conceptual model
A 4 independent processes
B A C D Processes run sequentially
B Only one program active at any
C
instant!
B That instant can be very short…
D
D
C
B
A
Time
5
When is a process created?
Processes can be created in two ways
System initialization: one or more processes created
when the OS starts up
Execution of a process creation system call: something
explicitly asks for a new process
System calls can come from
User request to create a new process (system call
executed from user shell)
Already running processes
User programs
System daemons
6
When do processes end?
Conditions that terminate processes can be
Voluntary
Involuntary
Voluntary
Normal exit
Error exit
Involuntary
Fatal error (only sort of involuntary)
Killed by another process
8 Chapter 2
Process State
Process Creation
Parent process create children processes, which, in turn create
other processes, forming a tree of processes
Generally, process identified and managed via a process identifier
(pid)
Resource sharing options
Parent and children share all resources
Children share subset of parent’s resources
Parent and child share no resources
Execution options
Parent and children execute concurrently
Parent waits until children terminate
A Tree of Processes in Linux
Process Creation (Cont.)
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
fork() system call creates new process
exec() system call used after a fork() to
replace the process’ memory space with a new
program
Process Termination