OPERATING SYSTEMS (THEORY)
LECTURE - 3
K.ARIVUSELVAN
Assistant Professor (SG) (SITE)
VIT University
PROCESS STATES
=> Three State Process Model
=> Five State Process Model
Three State Process Model
Dispatch
Ready Running
Time-out
Event Event
Occurs Wait
Waiting
Ready Running
Dispatcher selects a new process to run
Running Ready
Running process has expired his time slot
Running process gets interrupted because a higher priority process is in
the ready state
Running Waiting
An access to a resource not yet available
Waiting for a process to provide input
Waiting Ready
The event for which it was waiting occurs
Five State Process Model
process that has just been created
process that process that is
is prepared to currently being
execute executed
Submission of a batch job
User logs on
Created by OS to provide a service to a user
(e.g., printing a file)
PROCESS TERMINATION
Reasons:
(1) Normal completion
(2) Time Limit Exceeded
Process has run longer than the specified total time
(3) Memory Unavailable
Process require more memory than the system can
provide
(4) Bounds Violation
Process tries to access a memory location that is not
allowed to access
(5) Arithmetic Error
Process tries a prohibited computation, such as
divisible by zero
TWO QUEUES
Multiple Blocked Queues
Modes of Execution
2 Modes:
=>User Mode (Less Privileged Mode)
=>System Mode / Kernel Mode (More Privileged Mode)
Why ?
To protect OS programs from interface by User programs
How ?
PSW indicates the mode of execution
Process Switching
When to Switch a Process?
(1) Trap :
An error resulted from the last instruction(it may cause the process to be
moved to terminated state)
(2) Interrupt:
The cause is external to the execution of the current instruction (control
is transferred to Interrupt Handler)
Context Switch
Main Idea:
When CPU switches to another process, the system must save
the state of the old process and load the saved state for the new
process.
The act of swapping a process state on or off the CPU is a
context switch.
Context of a process represented in the PCB
Steps in Context Switch
Save context of processor including program counter and other
registers
Update the PCB of the running process with its new state and other
associate information
Select another process for execution.
Update PCB of the selected process
Restore CPU context from that of the selected process.
Context-switch time is overhead; the system does no useful
work while switching
Revision
Program
Process
Program VS Process
Process Image
PCB
Process States
Process Creation
Process Termination
Process Control Modes
Process switching
Context Switching