0% found this document useful (0 votes)
85 views21 pages

Three State Process Model Overview

The document discusses operating system processes and their states. It describes the three state process model with ready, running, and waiting states and the five state process model with new, ready, running, waiting, and terminated states. Context switching is explained as the process of saving the state of the current process, loading the saved state for the next process, and updating process control blocks when switching between CPU processes. Reasons for process termination like normal completion, time limits, and memory issues are also outlined.

Uploaded by

Riajimin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views21 pages

Three State Process Model Overview

The document discusses operating system processes and their states. It describes the three state process model with ready, running, and waiting states and the five state process model with new, ready, running, waiting, and terminated states. Context switching is explained as the process of saving the state of the current process, loading the saved state for the next process, and updating process control blocks when switching between CPU processes. Reasons for process termination like normal completion, time limits, and memory issues are also outlined.

Uploaded by

Riajimin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like