0% found this document useful (0 votes)
39 views

Unit 3 Notes Os

The document discusses computer process states and scheduling. It describes ready, running, waiting, suspended and terminated process states. It also explains short term, medium term and long term scheduling as well as context switching between processes.

Uploaded by

sameerjohri8
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)
39 views

Unit 3 Notes Os

The document discusses computer process states and scheduling. It describes ready, running, waiting, suspended and terminated process states. It also explains short term, medium term and long term scheduling as well as context switching between processes.

Uploaded by

sameerjohri8
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/ 25

UNIT3

Fowcess Statu-
MM
M M STS
( N e w ) T S

Ready Kuwug} (Tekiatt


MES
bi pi/ 7
/ Kaguest

Susperol
wit/
RLadlt SP BID MTS
Suye

BnttHEN
Suspercl

dicgaum wait

o but SM
SH).
stala
S u L f e a

vasioug
eugh
The oceLs passus ui abet
stah , Hhl pocws
Ctateol, t
n is t d
0 N oeateel,
be ceat but notHeE
picked b y eHhe
t n SoH pitkedTby
ROhich
Hhe pro9ham
catiHHeProAR
0So a prupa
pot,
Ht Creating a
Ate S
s tta
at e
Rady enter& he
Hhe
lady
Pw oadeo
nto
he id Teady
Hhe poDceL Hhat
av
a n e ody
ie eAL fn a
nmmDrY maintaind
Maun .
&nRaIL

ex ecutf
fos

ii choseh by
TL poocLs
An aUd
3 Runhi vq fos ex
ecutf
CPU executed
du
He f s t u c t i ens
(4) Ot Blaked- Whenuwes H proceAS UHOts
acceA to /o
uhput yem Hh uil) it eters H
uwait Block state P 0 s Conttiinul
to wait wn he Main memy avo
doe o t dLeaui re CPU Once ID epeoton
Pfosmed r complettd H poces Goes
Lady Statt

Temi natton [ lomp leti an- When a prc8

uish atexeut ony t cems


he telminaion Statt The PCB
centro) Bloek) is deleted
Susped Wait Plouk
P7ocRisLohich was p e p o m v q T o
lack e
&peation Qnd du Tob dto meve
Caulel hum
mair memDEY
O n UDK
momyoy
seconda ma t o Superd

ad Stat
ua
-Prcs hat
Suspend Koody
in Uady Stak
but
m
meau
inn muma
Enitfaly &ut om
Swapped storage
w e extena

Srtto
s u s p n d Racdy
Placed Keady
be in
s a f l to
and back to feady
prOC gves
Stat T
Statr whon m

awcula ble
SchedulA
Aschedul aa type o Stem 9tun
Hhat alleus o hand potoL
Schedulng
TUl au 3 types e ours Scheoul,

Shes
L e n a Tetm Te
Scheclule
Tem Schedul
Sehoeuls

Ten Schedulu'- Aso


Known a r Teb
) L&ma Schdul, T selecta

proceA m m he 9ulue avnol


Loads Hhun Pntohe main m e m b A
decinern
maj
a b u t hou mauy
makis a
to sta n Hh
P0CLA
Shwuld be made
latzr
He degu
Stact:
wady
multi poqamming
s- ICneDn aR CPU
Shot Tem Scheduls Schedlg Ttdudos
be execut ed next avd
ohich psDcA8 to
d apateh meel
Call a
stath
UWady to uunnivg
P o d CoA& em
venLas. T is Bntextt swithuq,
vic
Mdium Teum
Shedu Suspeni On
(3 deien
T
taken
ued
t e m Schedul
by meei wm
vgHhat ui mevPrg Hhpateo
fo%
fos Suoapp?
to seerdoruy rnernoa
em man momoy
and vie-veia
YoucessCemttebstorte
mhes

Suap-in Sumpred-dut Swp-Uct


Medium Pocseg f t l a l l
dodidu
xedcc_

short Tem C
Long Tem Riady PU Procas,
SCodudn", Sudeddul Tenvat

(Ccne

om
SeAOrdoh

T]odwia
Buout woihg

Context Switchi.
Contx switu H h i swtcie u
CPO om 8ne poceK p a n e h ProcAR
LOmdert Swtching
Sewel aoos A C x e c L
TnteupSelen Peoos
hneLo p2oce8 So Het Saue state ivtofra
Old proc Can Oa Fselated statetabm PB,
PxecutL Hhe shmu

Pot vewhae it stopp nteaR Spse, |executi

Swe state ivo ReB


1fdle
Te laled sbt ftm f

EXecia f a Shewng cPU


S o t oom hode
COCPU Jhodinq
paK012 detrhwiniq
CPU Shedubing a

get
while anoh p'abt e . 1 0n hold

Obfet'ves
(PU uslizakDn
() Max.
) feü .Ubatton of (P
(ui MaY lhunughmut
Minimn u a l b g Tmo

(V) TraONLKO Tfms


(V Min
Types Scheduling AlGp
CMni'pual

sRTE Riváty Pobbivn


FCFs STF
hudests MAe Sbedulive Shoplyi
(Fst Cme o moini
Firt Seve) Tob Timeiud
t
Boic Twms,
Hhu tima
at hih
at uwhih
T
A J s i Tme (A-T);- ún duocd qulus
uives
H prouy

( T) Tm at whih pates
ornpleti'on Tim
npletu e x e u i n

But Tme T)%- Trn eauised ty a

to CPU eXecuuli Gn.


rooy ,
Tun AdUnd i me (T-AT):
TAT T- T |
cempletion im
me dihence betuween
CUnd a l val bimu
dleOnc bete en
(w.T«) Tme
Oatina Tm
T AT nol buut
w T=T.AT B.T

Respense TmalR:T) wol


Sub miss{en a Ju0gtC O
betuoeen egjuit. Mininum

DRPONse to Hhe
lpens e
tfme i 2*od

. Pesfosmanc Coitesia -(Schedulivg, CsPtesio)


is H bas
bal
A petornmanu o i t e n f a
measutg eicdeny e Sebuduliq9
a l a t hm
vasieu& petomance Citesia asne-
The
CPU Uilsatt en' T mean uCPU

mult not be tdl e and


t t
i shDuld bus as much a& Pos21e.
T maximum CPU utt lrsatidn.

Toouaputs T mAan heuo manu

unt +fme exeuted pes


PoOc&Le

bette o
Highs thLouhpt
Petomance

TAT Min. TAT


wT Min uO T

()R T T
Fst -

Come r s t -SeaVe FCFS)


oLclL
n FCPS Schedulfng He povcess
UL
in u d y 9euL
C t ves t
CPU He
stt aiignealget
en pseemPHve
algo
Caleulat
blemPooces Asriva Bult
Avg aitig
T'm TP
T &
4
PL Phug Tu9n
S
P2 hobund

O Teme
P3
PY
PS 3

Soln Gnantt Chat

P3 P1 Ps P2 Pi
2 |3

Saml asd val


Tdletime P2& Py have
CPU P2 has S m a l l y
m but exeuted E
PoOcLA id
So P2

CT A w aT-BD
TD.
(ToA:T-BT)

PL -3= 4
8-3S
P 3 13-S=8
2-0 2 2-2-o
P3
9- 8
Py 14 Iy-5= 9

PS10 I0- 6 6 3 =3
=5-8 wnt
4t8t2t9tC =29/
AvgTA T =

5
Avg T -OtS+0t8+3 32 uut
Pobleha CPU BLt Tem Supfosee Hat
Padcerd asHivd
3
Py en Hhe qulut
P3 Calclat
w:T 9
P2
P I7

Gcutt Chast
Soln
PyP3P2P
29
2
Ot3+8t12
CT T-T wT =
Avg
Py 3 O
P3 8

P2 12
P 29 12

Acuarctages,. tor
( c i t , notge
does ot dead to Stavatien. ePu)
easy to Lnoli-tand

saduavtagl
T means
Sulhes e m Convoy efect
ave hg bust +ima aaive
a poOC8
bu&t +ime
hanHhe S m a l l
waut
engtime +o9
CPU
)STF (Shorteut Job Fist) Schaduling
CPU ii alignsad
n SJF Schedullng , 4 u
smallst bukt
H pooces having
tme
S3F nen- preemPive algo
alg0

Censldi the v e n beko-


Qus a t L G{vn
O
tme bumst
annival tf me &
Axival Timt Buiet Tme
POca& id Calcaulat
3 awg taiug
PL
Tim &
P2
A 2 ue T-AT

P3 using SJF 9
P4 6
3
PS

oln Cnatt Chast


P4- PL P3
| PBP2

12 16

PS
PPS
PS
Ag.T-A T 4t1SS76tH0
Prust id CT T-AT wT
4-13 S
P 7-3y
8it
P2 6 G=IS
-2-3
P3 G-y
6-6 0 Avg-wT. 3 t l 3 t D t T
Py 6-06
2-2=1d b-37
PS12
4-8uit

-2
woittnq m e usiva
Calulat aw
STF
BuystTim
PvocNb Arrival Tmt
3
PI
2

P3
Py
Gnaitt C h a r t -
oln Py
P P2
P3
1 py
P P2
P2 Py

w T
TA:T
CT -32
6-1S 8-y 4
P1 6 lb-2 8 2-2 0
P 10
3
3-1-2
10- 6
P3
3 wd
P
+4t0t6

Avq. w T
4
Frst) 8
TFme Hst)
Tme
Remalntnq
Shtest Pseemplien
with Pseenplien
3SRTF STF oth
aL
ChADnu
also

prremptive i n nalise
algo.
Calculate avg
BT
ouaidd AT WT aud

Regpens TPml
P 3 Oeach pocets
P2
2 using SRTF 9
P3 J
Py
Gnantt haurt
Solno PP2 P2 PPYP:P
L
P1
P PI4 PI4 P3y
P2-3 P2-2 P2 P2
2 P34 P3 Py-| Rsponie Time

T AT
wT R T - CPU fist fm
CT - 0-DO -AT
- 9
P 3
3-3-1-
1-y- -2 7
#0

P2 13
4-1
5-y
13-2 1 -104-4
4-4 70
0
P3
5
P vg.w.T=4+0t*70 -7S

KsPenle Tme
P2 0D
P3+
PY 0

howssTd
ATT BT Calceloct

aug T A.T,
Pootlena 3
P awq. T
1
P2 2 Cwa. R T
P3 usng SRTF 9
P
PS
a ctt
Sol
C h a s t

P2 P P2 P3 PS P
P
8 6

PyS
P24
unlt
hvg. T
P T =}
3.8 wnit
Avg WT =
l'6 wd
Avg 0t 0 t2tot6-8
=

Pvg
Hvg RT
Advatas8 uhantees
quhantees
minimun
minumum
optimal&
SRTP
(
waitfng m

sadvateage4
yatienn
sBa
l a d s +to tor a foDCeLiep
Canot
be set
Wasuge bust fme
odtieA
Pi
hawing
ml
Am.

(ii Poor
UuipeNLe

hawe

KPnd Robin Seheduling


CPU i aslgrd
Ht
nRR scheduling, FCES tor
basi o
+o popcess en
ambuit e time T h i
xed
h e o n , as Time 9pantam
expires Hh
H h
Tm antam
Ate Hhe preempt
anoA
Uunnlg ProCeS8 i OUrol
CPO

he URady quOL POOCLLR


pooculi
Sent tO huxt0 asrived
a s g np
e od to
eemptive
thi in natuse.

T
FC FS Schedulig

pseempHve mode
n
best perfoomanct
Advantane T ve timl.
Advand auvg uiponse
telms
Ttme Shaliy System
isadnvtoei) Leade to staAuaten.
( Pesfo-smant is deped S n
Tme Cuantu
iorih'es Canot Set or t
PoOCoALel.

quandum
-2wtt/
u os Td AT BT Th Hme
Calclatr awg waittg
5
PI dti'm, awg. TAT&

P ufng
P3 2 awg. R T
RR Seduling allgo
P
8T

P2 2
Ps2
PrPAPrpp
Readu

PPP P P
Cantt Chasty

P-ots d| C T TA T T RT
2 2
P
10
P 2
y
P3
S
PY
12t10tytS=+4sunit
T AT
T=tb+2+y 4 S wr
hg
Av RT =
AT &T T uAt
P
Avg TAT : 2
P2 AvG T 9
P3 2

4 3
PS

Sdn
Pl P3, P2, P
Raaly PS, PI, P2, Ps, Py
Gpantt Chaot

PP2PsP P PSP2|P1|PS
02 2 2 13 1y
Avq.TH:T 13t11t3tAtlo 86
uwlt

Avg w:T: 8t8+ 2t+7 S8urt


S
5)Paievlty Sehiolulog-
Schdulivg, thi CPU u auignocd
t .
PocoRs having tu highut prieIt
Pai ostty schedulig. Can be ues in botw

pseemphive wd nen- preemptive mucl


Piesity Shudulevg
Preempive mcl
Non- oeempHve mpole

Qus Procsid A T BT Pioity He cPU schaduliug


4 2
Policy Priy
n E n -p s e m P l i v E
Pi
3
'T and Hvq
P4 3 TAT Highie ho
PS 4 epret ighiuL
Pmom).

Bol Gnauctt Chahti


Pi P4|PS P3 P2|
4 11 12 1S
P2
3

4+14tDt6tT 8.2wit
PNG. TA T =

5
WT 0tl +9 tltS 52
Avg
okose AT
Hu set e s prbcoRseS
Ceniidu
TA:TL A9.wT.
&B:T ae Given alulat hq
etoiy Ppecphiue schucuulin.
wtng
A T B1 Paioity
P 4 Granitt Cast
P2
P3 2
P 3 PI P2P Pu PsP2P
2 8
PS 2

Phvg TA T =76wut
Hug w T =L 6 uhut
UNIT-3

THREAD MANAGEMENT IN OPERATING SYSTEM:

Thread:
A thread is a flow of execution through the process code, with its own program counter that
keeps track of which instruction to execute next, system registers which hold its current
working variables, and a stack which contains the execution history.
A thread is also called a lightweight process. Each thread belongs to exactly one process and
no thread can exist outside a process. Each thread represents a separate flow of control.
A thread is a path of execution within a process. A process can contain multiple threads.

Process vs Thread?
The primary difference is that threads within the same process run in a shared memory space,
while processes run in separate memory spaces.
Threads are not independent of one another like processes are, and as a result threads share
with other threads their code section, data section, and OS resources (like open files and
signals). But, like process, a thread has its own program counter (PC), register set, and stack
space.

S.N. Process Thread

1 Process is heavy weight or resource intensive. Thread is light weight, taking lesser
resources than a process.

2 Process switching needs interaction with Thread switching does not need to interact
operating system. with operating system.

3 In multiple processing environments, each All threads can share same set of open files,
process executes the same code but has its child processes.
own memory and file resources.

4 If one process is blocked, then no other While one thread is blocked and waiting, a
process can execute until the first process is second thread in the same task can run.
unblocked.

5 Multiple processes without using threads use Multiple threaded processes use fewer
more resources. resources.

6 In multiple processes each process operates One thread can read, write or change
independently of the others. another thread's data.
Advantages of Thread

 Threads minimize the context switching time.


 Use of threads provides concurrency within a process.
 Efficient communication.
 It is more economical to create and context switch threads.
 Threads allow utilization of multiprocessor architectures to a greater scale and
efficiency.

Types of Thread: There are two types of threads:

1. User Level Thread


2. Kernel Level Thread

1.User Level Threads:

In this case, the thread management kernel is not aware of the existence of threads. The thread
library contains code for creating and destroying threads, for passing message and data between
threads, for scheduling thread execution and for saving and restoring thread contexts. The
application starts with a single thread.

Advantages
 Thread switching does not require Kernel mode privileges.
 User level thread can run on any operating system.
 Scheduling can be application specific in the user level thread.
 User level threads are fast to create and manage.
Disadvantages
 In a typical operating system, most system calls are blocking.
 Multithreaded application cannot take advantage of multiprocessing.
2.Kernel Level Threads:

In this case, thread management is done by the Kernel. There is no thread management code in
the application area. Kernel threads are supported directly by the operating system. Any
application can be programmed to be multithreaded. All of the threads within an application
are supported within a single process.
The Kernel maintains context information for the process as a whole and for individuals threads
within the process. Scheduling by the Kernel is done on a thread basis. The Kernel performs
thread creation, scheduling and management in Kernel space. Kernel threads are generally
slower to create and manage than the user threads.

Advantages
 Kernel can simultaneously schedule multiple threads from the same process on
multiple processes.
 If one thread in a process is blocked, the Kernel can schedule another thread of
the same process.
 Kernel routines themselves can be multithreaded.
Disadvantages
 Kernel threads are generally slower to create and manage than the user threads.
 Transfer of control from one thread to another within the same process requires
a mode switch to the Kernel.
Difference between User Level thread and Kernel Level thread

User level thread Kernel level thread

User threads are implemented by users. kernel threads are implemented by OS.

OS doesn’t recognize user level threads. Kernel threads are recognized by OS.

Implementation of Kernel thread is


Implementation of User threads is easy. complicated.

Context switch time is less. Context switch time is more.

Context switch requires no hardware


support. Hardware support is needed.

If one user level thread performs If one kernel thread perform blocking
blocking operation then entire process operation then another thread can continue
will be blocked. execution.

Multithread applications cannot take


advantage of multiprocessing. Kernels can be multithreaded.

User level threads are designed as Kernel level threads are designed as
dependent threads. independent threads.

Example: Java thread, POSIX threads. Example: Window Solaris.

Multithreading:
Multithreading allows the application to divide its task into individual threads. In multi-threads,
the same process or task can be done by the number of threads, or we can say that there is more
than one thread to perform the task in multithreading. With the use of multithreading,
multitasking can be achieved.

The main drawback of single threading systems is that only one task can be performed at a
time, so to overcome the drawback of this single threading, there is multithreading that allows
multiple tasks to be performed.
The idea is to achieve parallelism by dividing a process into multiple threads. For
example, in a browser, multiple tabs can be different threads. MS Word uses multiple
threads: one thread to format the text, another thread to process inputs, etc.
(2Reocllpek dwetelovtl t
set
ndes maintoinivg a
This St oategy "madt
modt
a dicision d
olh
dato uig
wing
enttain a
tr
nou) &ugust nib
wluthe do SoquRt
CaLulel
hlu
entutaivuq Hhe
move A an wntale Statt,
Hhe
he Syetem to
it i dii casded

Banket's Algooithm

X Bankex's Algoaltm Bankee's AlGo i a

dtadlede avofclanet strattg4


Kemaining Need
Avclable
Max Need ToHal-Tohl
nilbee)_M
NeedAilcatEin)

Cut' Proc Alle cation


ABC AB C
A C AS c A P z Ned
1S3 33 2 74 3
PI 5 3 2 2 2
32-2
OO
P2 2- 66
P3 3 02 q02 14
42 2 7 4S2
2
Oo2
533 7 S 5 3
PS
2S

E10, B -5, C-7),


Tikal
&
i s ta
arrc
s

speifiestHil
no ef
U u b u s c e type
e tlat
Allocat'en
Cach
proePoDse

alloattd to Hh e Cack
been O
is the
Neeod:- Max that a
dUouAE
Max Juiouses tupe
pooCoys coh LcGut
pe a t o
PnetarcaR

vAvailable- The no. ttse-t


Cusotiy
avulab
Cach cusoul Le tupe
each ROuke
Sgouie
e Each
No inttarce
Kemaiuvq heed; procuc
ulapte
Ha a
type
execututn.
tov
Pvcutabt Aleillable -
Tota&Kuouke Alotatidrn
Avotlaslc
Allocatio
Alocation
MaxtNeed-
Kemainiiq Need

to
tollouos a Sal-c Algo
banuess A1g0
UuR ulbvg
stat t laf
check coutus ht
Statt nt
evctest o i sale b ut allo
allo c a t he
cati
Hhen
Tf ut is a Safe stat1 Otha
UuiousListo
tepotte
uegusteol
pseuieus Stite
t Siollback Bo fk
wfse
to be in
Sygtem soid
Scefe Statt eprCLL
Cah be
Ohen ll
LOIH
SequenCL L OIh
Sae stote seguOnCL
09ubitauySDm
ed u
exeiuct
wmbe o
awoul lable
he

NOu eta satisied


Sotisfied +
+Hon
o
asl eta
wmainivg
nuo SugeeceQ
2 u lllo
u osse
e
execuitt
P
shccesstully. P s e u i e u i O w a l a L l e

32+ J2 o 0]- Al t2
NewAvailate-[3

5 32
No Pu ud
olvol
satisdied. Py Succers fully executed
Qtes ex ecuctibn eultoLe SusouCa
Neuo. haike:-532]t L2 t3 43]
NLo P i SucceLdfully ex ecut eo
Pvouilable -[7 y31+ [oo 2)
L+4S -

N Gu P, erecuta
AvoilaHe L14s]+ [o 1o] C7 5 S
P3 execut Sekceevsul
Seapuenct
PaPyPs > P ->Pa
Sae sequonee and

s
So,
t a

Occus
wil not
oLlock

oll8wi Snapshot a
Quas& Cened He
System
AllocaiCn Max Aveulade
ABCS A BCD
ABCb
06S6 620

o0
P O632 O6S2

Pa OO2
O O12-
T7S0

reod mao)x 9
notc mablk
ert e
Ohat iu He cont
i n Sale stete9
a) Sale state 9
in
Hhe suelem
b)Ts
(
son Need Max- Allocatb
Need mat.ix:
A_B D
66 4 2
20

OO 0O
P

0 5 0

Need Avallablethen tivd ntuo awad lable


No
NDle

NO
P Io 6 4,23 LI6
Loo 2o1 SLi6 2 03 Ye
P2
lable=vailable t Allocahen
Prvat b 020
6 2.0)t (
L 6 40o
Loooo] < Ci 6yo Ye
i64e
hvouilable I64o)+ [o o o]
o -

PyLo Sol< LIG 40 No


o 6y2)S [IG Yo7 No
f i o t ün Sale stt
U, System

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy