Paocess Schedui
queue header PCB7 PCB2
head
ready paadL
Ue
queue tall registers registers
mag head
IOdeuices
tape tail
unit 0 Giee
mag
tape hea
tail PCBa PCB4 PCBg
unit 1
disk head
unit 0 tail
PCB5
terminal head
unit 0 tall
a a m u l i paoquammioq evisonmesb, the
ProLess Scbedulei Selects an aailable process
o Progkam execuion on tbe Ceu
SAs Pocers enters h e System, they put nto
a- bqueLue
be psocesses -that resio%e o main
ase
memary
and ae eady and awaiting to execute
kept Gn a list callec the ady queue.
Linhed L'st s t h pointeas Loqixst
n a l PcBs
be queue with list o Procesces
a
aiting ya
a patculas L I O deuice S Caued a dezice
Scucing DiagA m
ready queue CPU
VO queue VO request
time slice
expired
child fork a
executes child
interrupt wait for an
OCCurs
interrupt
A psocess 15
neuw
initialy put ib he aaadu
qucue. It waits tbuu urtil i6 is Selected or
execution, Os dispotcbed
Once h e process is allocaled CPU and s
exet utng, One o scvekal events Coulo accu..
Ihepsoress Could issue a n TJO uquuest 4
ten be placed in a n LJo Gue u e
lhe pAOLeu Could Cacate n e w chtld
pakoasb beqade
Paocess andwait o r t e chilos teaminabos
Tbe paoceSS Could be aemoved q0sCbly4xom
h e CPU as a sult o4 oD intexTupt an be
put back i'n h e
aCdy queue
Activity2
For events & 2, iden tiq the process
SEat es t b a t coTzeepond to h e evestS.
PnAwea
Egees Lo wailinG" SLcte Eheo back
t
too "sady ates Complutioro
a d y quee
Scheduless.
Long-teamJob Schedulae
the
Whenmultiple processes aue Submited,
S s e s Cle Seooled to a mass Storaqe device.
Proce
t s p*OCeLscs Jacm h i s Pcol
Job schedules selec
Eloads thcm mto memOY j o execu ton.
Shoat -team/CPO Schedu les
Selectsqrom among the processes t a t are
ready to execute and alocates CA to one oj
Lhem
propes
Scbeoduls mvst Select a
The lvng tam CPO-burd prOCessee
TlO-bound aod
mie o
L)o bouno, the reaoy q e
ue
all prOcessEsake
a n d b e shoxt-
shos
wil almost always empty
be
Lttle to dob.
team Schedule w i l l b a v e
tenm
all e prOcesses aAe CPU-bound, the I/Jo
L4
wiu dwaye almost alaye be
Wating queue
will go unuued, a n d again the
empty ,deoices
System wiu be unbalanced.
Tlo-bouod: Spends oOre timedoinq Ilo
CPU-Louod wcs mdre o4 its time doing Computaton
Long-tumScheduler controls the d a g i O4
MultiAAcg mmi-
ytheumbe 01 Proce sies in_nmemory
Hou to inprove proces mie
Swapping
move thbe rocess
àOm memory &
LatuUu-introduce to Comtine the
eecuton qrom bcs It
let o
CSwop out, Swap inS
Lho docs that?
medium-tcom_ Schecdu lez
psabab beqa de
Swap in partially executed swap out
Swapped-out processes
ready queue CPU end
/O waiting
VO
queues
Context Switch
Swith'oq tbe Ceu to adtbes process by-
Savibq the State oj Cusrent proccke LPcA) S-
ustoring tbe State of a disjesant poces iss
Context Sutch.
Calleo as a
as be-
Coptet Switcb time is a pure Ovcs-bead
work_while Sutching
System doeg DO usejul
Key tams i
CentexE
State save.
Staie rcstore
nATE Question:
be
be 04 PrOCesses that can
Ihe m a i m u r A u m
Computes wth n
'nPraady
State yor a
CPUS is:
a) n 6> dndependent ay
Answe d
Long-Term Short-Termn Medium-Term
Short term is also known as CPU
Medium-term is also
Long term is also known as a job
called swapping
scheduler scheduler
scheduler.
This scheduler is an
It is either absent or minimal in a It is insignificant in the time-
element of Time
time-sharing system. sharing order.
sharing systems
Speed is the fastest compared to
Speed is less compared to the
the short-term and medium-term It offers medium speed.
short term scheduler.
scheduler.
Allow you to select processes It helps you to send
from the loads and pool back into It only selects processes that is in
a ready state of the execution.
process back to
the memory
memory.
Offers full control Reduce the level of
Offers less control
multiprogramming.
hxeads
Paocea is aPaDgram that pcayoams a Single
Jhread oj execuion.
seA Cannot SimulbaeOusly tyee in chaxcc.bexs-
E suo the Spell cbeckes Within he ccme.
PAOCess,
Multple hreeds Cao Auo in pasallel Os a
Susterm that Supports {reads PCBis eupanded
bo include irjormation 4or each threaae
MCG
PCB oy
*PCB o4 al
all the Cusrcn t Pcescs have
a. Proces Reqislea aentry in
b. hocesc Toble
C. Praxarn Countu
Aoswer b
dProcess unttt
paecb
Opesaucns OD Pocesscs beqade
Most opeiatng Systems
to aunique
identi poccsces accodng-
Phcce ssicdestquciLpid) whib is
typicay an
inteqei Dumbes
W can obtain a
usting pao ces uing4Lowig1
CCOmmands
*ps.
ps el
he ioit prOcess_Scaves as aAoot PaksaE proLess-
0 a l l us eR paOcesseg
Paocek id a ioit is always 1 (coe)
Scbedules process Ckoowo as 8 a p p e ) bas
PID -0.
Commond to See tbe process Creation tree
rec
Pstre
To get pro ce se id and paven t process id o the
Currenb process w e u e the yolowingunctons
oo <unistod.b>
getp'dC) tuw n teqe
g t Ppid ( )
ts a child process
when a proce cs Caca
- A Child paoceck may b e able bo Obtain ite
ite
OS
Csour cos di>ectly à m
Constzaincd to a Subset a the recouace
the
pocess.
O1 he paunt
he par ent may ave to paibition ts
its zcsos
eSouces
among its dhildsen o> it may be able to shae
haxe
Some esources ameng Severa l oj its Chilorer
Wen a paocess Caec tes O new process,
Ihe parent Continues to exccute ConcuYrently
with its children
he parent waits until Sorme r all a its
childrcn have teuminated.
Jhere
Jhere u aluo two address - Space possibiutis
O te ne paocess
7he
de child
proees ic a
duplcate t h e Pases
PucCess
L4bas Lame paogaam S data as he
aust
Tre
The CLo pocesc bs
ne
Loaded nto . pioguam
foskC
Erom the a n poaqe
fosk - Cseates Chila process
Finclude Lunistsh>
pid-tfoxkCdid)
fasbi Cacates aDewproceseb4 dupuCatnd
the Calinq-procesc
Dea erocesS Cbile
Coalioq AroLess PaxeaE
They both
Jey iun
in Sepasat memoy spoce AE
he time o4 foxhC) botth memory Spaces bave
Same Conteot.
Child i s exact duplcate o panbexcepb6,
to name a e
chrlo bas its owo Unique pid.
childh pasant process id S Same a s pasents
PAocess id.
Ps ocess Arsouuce u t i t 2 a t o n s a n d CPU Lhe
Countex6 aA eset to 2eso n b l l d .
The temimaton sqnal O the child is
aluays SICHLO
3he child doa not inhe» its paventss
memoyLo ck S.
pusabaeb
Ketuan lqpe
beqade
On s
the PlD 04 Child proc e s i s etuned to
pasent is detuunad in the Child.
OFailuse
l i s retwned in h e parent, bo Child is
Created, and exno s S c t to naicate b e
exroA
Pacgiam
ÉDcludecstdio.b>
Finclude Lonista.b>
int main)
forkC)
PinttC ospp\"S;
utun 0,-
Output.
OspP
OsPP
Both
oth paunt and child
Hence
patnt OsPp_on
Outputs Ospp twice,