0% found this document useful (0 votes)
13 views29 pages

Os Moduletwo - Process Management (Part One)

Uploaded by

amansumesh71
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)
13 views29 pages

Os Moduletwo - Process Management (Part One)

Uploaded by

amansumesh71
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
You are on page 1/ 29

OPERATING SYSTEMS

PROCESS MANAGEMENT

Dr.ARIVUSELVAN.K
Associate Professor – (SITE)
VIT University
Program

A program consists of:

Code: machine instructions

Data: variables stored and manipulated in memory


PROCESS

 Program in Execution

 The instance of a program being executed.


PROCESS
A Process includes 4 Segments:

CODE / TEXT: Holds program

DATA: Holds initialized program variables (Global variables &


Static local variables)
BSS Segment: Uninitialized data

HEAP: Holds intermediate computation data generated during run


time

STACK: Holds
=> Local variables
=> Temporaries & Procedure Calls
=> Return addresses
EXAMPLE
EXAMPLE

Hello Students

Welcome to OS

Operating Systems
STACK Frame
Stack Vs Heap
PROGRAM PROCESS

Instructions in any Instruction execution in machine


programming language code

Active Entity
Passive Entity
{Contains program counter,
{Content of file stored on
specifying next instruction to
disk}
execute}

Resides in the Secondary


Resides in Main memory
storage
PROCESS IMAGE

Process Identification
Process State
Information PCB
Process Control
Information
User Stack
User Address Space
(Code& Data)
Shared Address Space

 The Collection of attributes is called as Process Control Block


(PCB) or Task Control Block (TCB)
Process 1 PImg-1
Process 2 PImg-2
.
Process n PImg-n
Primary Process Table Process
Image

 The address of each Process image is stored on Primary


Process Table

* To maintain the process, its image must be brought into main


memory
Structure of PCB

Unique ID provided by OS on process Identifier


creation
New, Ready, Running, Suspend, State
Terminated
May be Internal (Set by OS) or Priority
External (depends on external
factors) Program Counter Address of next instruction to be
executed
Includes Pointer to the
=> Program code
Memory Pointer
=> Data associated with this process
=> Memory block shared with other
process
Context Data Data present in Registers, while
process is executing
Includes
=> I/O requests,I/o devices asssigned to
this process I/O Status
=> List of Files in use by the process Information

Accounting Includes the amount


Information => Amount of processor time
used
=> Time limits
PROCESS STATES
Five State Process Model
process that has just been created

process that process that is


is prepared to currently being
execute executed
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


TWO QUEUES
Multiple Blocked Queues
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
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 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
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