0% found this document useful (0 votes)
10 views22 pages

Process Management

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)
10 views22 pages

Process Management

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/ 22

Process Management

 Process

- A program in execution is called as process and it is


also called job task or activity
- It is a active entity that require set of resources like
processor, resister and counter for execution
- Multiple processes may be associated with single
program

In execution
-
Program Process

 Memory Layout

- In memory layout we describe the internal


structure of memory
- It shows how the memory is distributed for
various part of the program when the program is
in ready queue
- It consist of 4 main regions
1) Stack region
2) Heap region
3) Data region
4) Text region

Environment
Variable
Stack region

Heap region
Un initialized
data
Initialized data

Text region

1) Text or code region :- in this region we store the


code that the process execute
2) Data region :- In data region we store the
variable of program

There are 2 types of data region

- Initialized data region :- in this type of data region


we store initialized variables of programs
- Uninitialized data region :- in this type of data
region we store uninitialized variables of
programs
3) Dynamic/Heap Region :- the heap region is
used to store the dynamic data of the program

4) Stack region :- in the stack region we store the


instructions in stack format

DIFFERENCE BETWEEN PROCESS AND PROGRAM

Program Process
- It is a passive entity - It is a active entity
- It is a static entity - It is a dynamic
entity
- It is a set of - When a program is
instructions to in execution is
perform a particular called as process
task
- Stored in - It is stored in main
secondary memory memory
- It is a set of process - Process is a part of
a program
- Occupy fixed - It changes
storage in memory according to its
execution
PROCESS STATE

Process state has several stages that it passes through


from beginning from the end. There must be a minimum
of 5 states.

1) New
2) Ready
3) Running
4) Waiting
5) Terminated
1) New State :- It is the beginning of the process.
Initially the process is created here so the system
creates a new process using Fork() system call. A
new process is created in this state.

2) Ready :-

- In ready state the process is loaded into the main


memory
- When it loaded into the memory it is ready for the
execution
- In this state the process is waiting for the CPU
allocation

3) Running :-

- In running state OS allocate all software and


hardware resources that are being required to
execute current process

4) Waiting :-

- While executing the program when a process


needs to perform I/O operations then it goes into
the waiting state
- Process waits in waiting state until the same
event occurs

5) Terminated :- when the execution of process is


completed then it goes into the terminated state. In
this state memory occupied by the process is
released

PROCESS CONTROL BLOCK (PCB)

- Process control block (PCB) is nothing but the


internal data structure to describe each process
- Each process has its own PCB, it contains the
information of the specific process
- When process is created by OS then it allocate a
PCB for it
- It is also known as process descriptor

Process state
Process
number
Program
counter
Register
Memory
management
information
List of opened
files

1) Process State :-

- Process state indicate the current state of the


process
- Process state can be new, ready, running,
waiting, terminated

2) Process number :-

- Process number indicate the identification


number of the process
- Each process can be uniquely identified by the
process

3) Program counter :-
- Program counter indicate the address of next
instruction to be executed
- It can store the address of the next instruction

4) Register :-

- Register indicate the CPU register


- No of register and type of register is dependent
upon the computer architecture
- Register include Segment register, flag register,
index register etc.

5) Memory management information :-

- It includes information such as value of database


and limit register, page table depending on
memory system used by OS

6) Accounting information :-

- It includes the amount of time limit used by the


CPU, job number and so on
- It also include list of I/O devices that are that are
allocated to a process such as list of open files

SCHEDULARS

- Scheduler are used to handle the process of


scheduling
- It is one type of system software which decide
ehich process can run
- There are 3 types of schedulers
1) Long term scheduler
2) Short term scheduler
3) Medium term scheduler

1) Long Term Scheduler :-

- Long term schedular pick the job from the batch


or the job pool and load it into the main memory
for execution
- It is a ready queue schedular and it has low
frequency for execution
- Speed is lesser than short term schedular
- It deals with main memory for loading process
- It is absent or minimal inn time sharing process

2) Short Term Schedules :-

- Short term schedular pick the job from the ready


queue and allocate CPU for the execution
- It is a CPU scheduler and it has high frequency
for execution
- Its speed is very fast and it deals with CPU
- Its minimal in time sharing system

3) Medium Term Schedulers :-

- Medium term schedulers remove the process


from the memory and reload it when it required
- It is a process of swapping and it has medium
frequency for the execution
- It deals with main memory for removing and
reloading the process whenever it requires
- Time sharing choose medium term schedulers
Explain the working of CPU switch from process to
process with neat diagram (Context Switching)

- In a context switch, we switches the CPU from


one process to the another process
- In context switch when we switch the CPU from
one process to another process then the at that
time we need to save the state of old process and
reload the saved state to newly arrived state
- The context switch of process is represented in
PCB
- When context switch occurs then kernel save the
current process in PCB and load the saved
context to the new process
- Kernel perform the following activities

1) Stop the progress of process and store


the CPU state
2) Retrieving the stored context of next
process from memory
3) Returning to the location which is
indicated by the program counter

- Context time switch is highly dependent on the


hardware support and context switch can occur
only in kernel mode
-

INTER PROCESS COMMUNICATION

- Inter-process communication means sharing of


data or information between 2 or more separate
independent processes
- OS provides functionalities for IPC such as
shared memory and message passing

 Shared Memory

- It is the fast and efficient method of IPC


- It involves creating a region of memory that can
be accessed by multiple processes
- In the region the processes can exchange the
data by sending and receiving the data to shared
region of memory

- Shared memory model is faster as compared to


message passing because shared memory
require less time than message passing because
it is implemented by system call

- There is no interaction of kernel in the shared


memory

 Message Passing :-
- Message passing involves sending and receiving
messages between processes
- In this there no need to share the address space
here messages are shared without requiring
address space
- Message passing is quite slower as compared to
shared memory because message passing
implemented by system call thus it requires more
time
- In message passing every message is shared
and received through kernel
- There is interaction of kernel in the message
passing

 Difference Between Thread and Process


THREAD PROCESS
It is segment of process It is a program in
execution
It is also called as light It is also called as heavy
weight process weight process
It takes less time for It takes more time for
creation creation
It takes less time for It takes more time for
context switch context switch
It takes less time for It takes more time for
termination termination
Share data with each It can not share data
other with each other
It can be controlled by It an be controlled by
programmer operating system

Thread are dependent Process is independent

 User Level Thread :-

- User level thread is managed and implemented


by user application
- User level thread are faster to create and manage
and they can be run on any operating system
- User level thread cannot execute simultaneously
- It support many to one mapping
- User level thread uses ‘userspace ’ for thread
scheduling
- Advantages :-

1) They are faster to create and manage


2) It can be run on any OS
3) It support many to one mapping

- Disadvantage :-

1) Cannot execute privileged instructions


2) It is not suitable for multithreading
modles

 Kernel Level Thread

- Kernel level thread can be managed by kernel


and implemented by OS
- These are slower to create and manage and it
can be run on only specific OS
- Kernel level thread can run simultaneously
- It uses one to one mapping
- It uses kernelspace for thread scheduling

- Advantage:-

1) It execute privileged instructions


2) It is suitable for multithreading models

- Disadvantage:-

1) It is slower to create and manage


2) It can not run on any operating system

 There are various multithreading models


1) One to one
2) Many to one
3) Many to many

1) One to one Multithreading Model

- In one to one model one user level thread is


mapped with one kernel level thread
- If there are 3 user level thread present then
system will create 3 kernel level threads and this
is drawback of this model because of this
performance is down
- separate kernel level thread
- ( no is user threads = no of kernel threads )
- One to one model is used to run multiple threads
parallelly in multiprocessor OS and it has less
complicated process

Advantage :-

1) Allow to run multiple threads


2) Less complicated

Disadvantage :-
1) Each user thread mapped with separate kernel
thread
2) Need to create kernel thread according to user
thread

2)Many to one model

- In many to one multithreading model multiple


user level thread are mapped with one kernel
level thread
- In many to one model one kernel level thread
control many multiple user level threads
- This type of relation provide perfect environment
for context switching
- It don’t allow to run multiple threads parallelly
and In this one kernel thread can block other user
level threads
-

- Advantage :-

1) One kernel can control multiple user level threads


2) This can provide perfect example for context
switching

- Disadvantage :-

1) One kernel thread can control other user


threads
2) It don’t allow to run multiple threads

3)Many to Many Model :-


- In many to many model multiple user level
threads are mapped with equal or small no of
kernel threads
-

You might also like