You are on page 1of 25

fflPII--M•pqIJONI OPERATI~G SYSTE M

llltlc: -umption mad• in the deadlock d e t e t'


1. Wl..a • the optiffl ,._,.? c ion a1
How can lhla aeaumption be viola,... tweu, 9orit~ . pold & Wail ery process in the deadlock state, must hold at least one resou rce
Auww: io, a(c"1? 41.,;d1fll that each & ev esource. We can avoid thi s Condition with a protocol
"Ille opti~istic assumption is that there will not be any fonn of circul a r Wan . S)) 11 fll'~s for at )east one:rawbacks, because it is very expensive and time consuming.
,nd ,-'ll~tocol has some •
resources allocated and processes makmg ':quests_ for them . This ass urr,Plio' n tcl"llis rh1s pr
violaaed if a circular wait does indeed occur '" practice. n co~ld ~ 11
. rtt,r1ptio condition •·no pree mption•: means r:sources ~re not released in the
I . With example describe if resources are not properly a llocated to the Pr ,o~hird necess:7essing. There are two poss ible techniques w_h~ch could obviate this.
C'Neu; ~~••e, ri,e I of the pr I dy hold ing some resources requests an add1t1onal measure which is
may lead from • safe atate to an unsafe state. it 1
f11 d~ ~fa process ~;::ss, th e requestin g p_rocess can be forced to give up the resources
A~ r. . .
A System is in safe state onl) if there exists a sate seque~ce. A seque nce o f r
18(1't)J
f
fi~ b) another1 v.ould then need ~o wai t fo r all the necessary resources. The second
11
( ,._ P. _y_} is a safe sequence for the Current al location s tate if fo P oces~ ' ntlY held . source R req u ired by o ne process and held by a second . could be
•• : • . r each p th
,u:billt)' is a; :r~: the second. T h is a pproac h is not feasible for_serially re~onable
resources that p_ can still request can be satisfied by the , !ht
~ "'-·,
~rcibl)'
10 but ,t can be us ed fo r resources s uch as m emory space, reg isters etc \.loh1ch can
rerno~e
currcnth available resources plus the re:,ources held by all the resources, d restore late r.
P such that j<i. In this situation, if the re:.ources that process ~ i,esa\ed an
P needs are not immediate!~ available then P, can wait until a ll C cu/ar Wait . . . .
;Jroidi11g " wait conditio n can be preven ted 1f ~esources are organized into a particular
P have finished. When they ha"e finished. P, can obtain all of _ _ __ Sare
fhe circular rce requests have to follow th is ord er.
order and that resou
the oeeoed resources, complete its designa_te~ task, return its a ll ocated resources
terminate. Wheu p tenninates. p__, ca_n ob_tam ,ts needed res~ u_rces and so on. ff nos::~
Deadlock Avoidan
th ~~ods of dynam icall y o r o nline escaping from the deadlocks. In this
sequence exists. then the S)Stem state 1s said to be_unsafe. Thi s 1s shown in the figure.
But not all unsafe states are deadlocks. However, 1t may lead to a deadlock It is one _o~ r:C::s req uest for resou rces, the avoidance a lgo rithm checks about _the state
method, tf e! before the allocation of resou rces so th at there ca n never be a _c ircular -
9 . Prove that linear ordering for denying the " c ircular wait" condition act of ~e S}~~tion. The resource allocation state is defi ned by the number of available and
pravents circuits from developing in resource allocatio n graphs . ua 11 Y ~:~~ ~~ resources and the maximum de m ands of the processes.
1
[WBUT 2019(CS)] t uoted avoidance strategy of this type is known Ban h:er's a lgo rithm . .
Aaswer:
The Circular \.loait can be denied by imposing a total orderi ng on all of the resou rce t)pes ;:;t;:~ r~fer to Question N o. 2 (2 nd
part) of Short A nswer Type Queshons.
and then forcing all processes to request the resources in order (increasi ng and
decreasing). This strategy impose a total ordering of all resources typed, and to require Long Answer Type Questio ns
that each process requests resources in a numerical order (increasing or decreasi ng) of
enumeration. With this rule, The resources allocation gra ph can never have a cycle. For 1. a) State fo ur necessary cond itions f~~eit;i~7 , 2008, 2011 , 2013(C S ), 2014(CS)]
example, provide a global numbering of all of the resources, as shown below: OR,
J= Card reader 2= Printer )=Plotter 4= Tape drive 5= Card punch; Now th e rul e is that What are the criterions for a s ystem to be Deadlock? [WBUT 2012(IT)]
the process can request resources v,henever they want to but a ll request must be made in OR,
numerical order. Write down a ll the necessary conditions of Deadlock. [WBUT 2013 (IT)J
OR,
10. What are the methods for handling deadlock? [WBUT 2019(1T}] What are the necessary conditions for deadlock? [WB UT 201 S(IT), 2019 {IT)]
Aaswer:
OR, for deadlock to occur in a s ystem?
Methods for hand li ng deadlock: ~xhp~;i~~e the four necessary conditions [WBUT 2017 (1T)]
Avoiding Mutual Exclusion d
It means that only one process can use the resource at time i.e. reso urces are not sha:i OR,_ •
What are the necessary and sufficient cond1t1ons for dea
dl ock to occ
[WBur?UT 2018(1D]
by the number of processes at a time. A process never needs to wait fo r a shara e
resource.
OS-53
OS-52
OPERATING SYSTEM
POPULAR PUBLICATIONS
following snapshot of a system where 7i(i =l..4) denote resource
¢,=:~ four conditions for deadlock:
i) Mutual exclusion: A resource can be used only .by o?e_process at a .
z,
cooSI
·der the
s aod Pi to s ,
.
P. denote processes. The vector 'Available' has usual meaning.

tyP'
process request that resot.ITT:e, process must be ,~a 1t un til II has been rei' 1rtie. If an 1,valfabfe r3 r4
0
ii) Hold-and-wait: Some processes mu~t. be hold in~ some reso urces in eased. ther
r1 1r2 o 0
mile and at the same time must be waiting to acquire some more reso u a non-sha 2 nt a/location : maximum demand:
currently held by other processes. . rces, IYhic:b/i curre ,1 r2 r3 r4 r1 r2 r3 r4
iii) No preemption: Resources granted to a process can be released b '"' process
O
o 1 2 o· 0 1 2
only as a result of the voluntary action of that process aft ack to the s" P1 2 0 0 0 · 2 7 5 0
, er the ,s1e
completed its task. . Process h lli P2 o O 3 4 6 6 5 6
iv) Circular wait: Deadlocked processes are involved in a circular ch . ijs pJ 2 3 5 4 4 3 5 6
process holds one or more resources being req uested by the next p ain s~ch tha1e P4 O 3 3 2 . 0 6 5 2
roc~ss in the cha~th 5
. P stem cu rrently in a safe state? Justify your answer.
b) Consider the following snapshot of a system : n. i) Is this 5 Y st from p 3 arrives for (0, 1, 0, 0), can th at request be safely granted
Process Allocation Max Available ii) If a .retq~ye? (WBUT 2009, 2014(CS); 2015(CS)]
~m~~e .
ABC D ABCD A Bco
Po O O 1 2 0 0 1 2 1 5 Answer: .
2 0 Need matri x 0
P1 1 0 0 0 1 7 5 O
6
_ o O 0
P2 1 3 5 4 2 3 5 - 0 7 5 0
pl 0 6 J 2 0 6, 5 2 2
6 6 2
P4 0 0 1 4 0 6 5 6 2 0 0 2
An5!"er the f~llowing question using thf!! Banker's alg or ithm: o 3 2 0
1) What 1s the content of the matrix need?
ii) Is the system a safe state? Stcp-1 p1 is selected
iii) If a request from process P1 arrives for (0 4 2 O) c th Since, (0,0,0, 0) 5(2, 1,0,0)
gra~ted immediately? ' ' ' ' an e request be Then, ava il able matrix= (2, I , 0, 0) + (0, 0, I , 2) = (2, I , I, 2)
Answer: (WBUT 2007, 2008, 2013(CS), 2013(1T), 2014(1T), 201 7(1T), 2019 (CS)J Step-2 P4 is selected

![I
Since, (2,0, 0,2) 5(2, l, l,2)
i) Need= Max - Allocation
Then, avai lable matrix = (2, I, I, 2) + (2, 3, 5, 4) = ( 4, 4, 6, 6) .
Step-3 P5 is selected
Since, (0, 3,2, 0) 5( 4,4,6,6)
Thorootemofb~m,u;xl Then, avai lable matrix= (0, 3, 3, 2) + (4, 4, 6, 6) = (4, 7, 9, 8)
Step-4 P2 is sel ected
Since, (0,7,5, 0) $(4, 7,9,8)
ii) Yes, the sequence < p_ P.. p P.. P. . . ti Then, availabl e matrix= (4, 7, 9, 8).+ (2, 0, 0, 0) = (6, 7, 9, 8)
iii) Yes, since o, i, " 3 , 4 > sat1s tes the sa fe ty s equ ence. Step-5 P1 is selected
(0, 4, 2, 0) 5 Available (i.e. I, 5, 2, 0) Since, ( 6,6, 2, 2) $( 6, 7, 9, 8)
(0, 4, 2, 0) 5 Max (i.e. I , 7, 5, 0) Then, available matri x= (6, 7, 9, 8) + (0, O, 3, 4) = (6, 7, 12, 12)
Then the system sequence is ( Pi,P.i,.fs, P2 , .f:i ) = ( 6, 7, 12, 12)

os..:54 OS-55
OPERAm.;G SYSTEM
PQMM Pl)IU.ATIQf§
five processes P, through P, and have th . uestion using the Banker's algorithm:
l. COMider • systam wlh wnbef of instances of each rHource typ re, 'll0i,._ tt1• following q tent of matrix " Need"?
,...,,,, hat ,s the con a safe state?
typea A. 8, C. f"and CMal then M8UT2 016(~;o d 'ltr~
the . . ~ ~

MAX HEED 1 AVAILABLE ,. 20,6<rtn ,. 1. W 11 the system in process P1 arrives for (0, 4. 2. 0) can the request be
2 , a ,,quest fdro~ely? [WBUT 2018(CSJ]
A 8 C A B C A B C
~

J I d imme ia
~P, 1 5 3 1 4 3 2 3 0 grants
Pi 3 2 2 0 2 0
Pi 9 0 2 6 0 0
pl 2 2 2 0 1 1
"fr:~i
I eJJ=:; 5
m of all needi, A= Sum of all allocation, .M =Sum of all Maxi. Use
u
P, 4 3 3 4 1 1 ~ ~jction to stprov~. ot deadlock free. If there exists a deadlock state, them A= m
~Ir. c;:e this ~ e~ •:~e kind of resource and resource~ can be requested and released
Mu :-.ttct A~ailablt usetheret~onYF mcondition(b), N .. A=\,f---m n.So,weget N-m---m+n.
A B C A B C .\ B C t,,:ea ume ro . cond" . ( )
__ ,, ooe at I{a <n, 1't Shows that at least one process '· at need,= 0. From 1uon a •,
Pe 7 s 3 3 2 3 0 IJIU, 1
are n - I processes shanng m resources nov.,
P, 3 0 0 , \\e get
0
1 t 1 resource. So there
1ease at eas ·11 • ti
P: 9 0 6 0 0 p can re (b) still hold. Go on the argument, no process W1 \\alt permanen y, so
,. ~ 1 2 0 I I di,ion (a) and
,on . deadlock.
P, 4 3 3 3 I were LS no .
Ncn., aIJocation will be= Ma., - Need
2"' Part: Refer to Q
uestion No. 1(b){iii) of Long Answer T; pe Questwns.
A B C
Pe O I 0
5 Write short note on Starvation. [WBUT 2019(CSJ]
P1 3 0 2
P: 3 0 2
Pi I I ~osl\er: . a condition where a process does not get the resources it needs for a long
P, 0 0 2 swvauon is th sources are being allocated to the other processes. It generall} occurs
ume . . b ere
· because ed scheduling system starvation· ·
·1s th e name gnen toth e 'dfiite
m e in
a pnonty o~ a process because it requires some resource is never allocated to the
We tmJSt determ:ne whether this~ ~stem state is safe. To do so, we execute our safety
inpastponernent
algorithm and find that the sequence <P., P), P" P.,, Pi> satisfies our safety requ1reme•,1.
Heocc. v.e can immedia:ely grant I.he request of process P1•
The need of P is 7, ~. 3 which is too ~eat for the 2. 3. 0 that is available. Therefore. lhe process. . a Process .is ready
In starvauon, . to execute but it is not being allo\\ed to execute. Here
safety algorithm v.ould skip over P0 in its search for the first process to have its finish request may be differed infinitely.
sim..:laied. The need of P1 is 0, 2, 0 which nowhere exceeds 2, 3, 0. Thus, P1can be given
its need and made to finish.

4. Explain Circular-wait for the occurrence of deadlock and how it could be


prevented. Consider a system consisting of m resources of the same type being
shared by ' processes only one at a time. Show that the system is deadlock free if
the following condition holds:
(a) The maxjmum need of each process is between 1 and m resources.
(b) The sum of all maximum needs is less than m + n.
· snapshot of a system:
Consider the foII owing
Process I Allocation Max
PO Available
I ABCD ABCD
P1 ABCD
0012
P2
P3 I
'
J 1000
1354
0012
1750
2356
1520

P4 I 0632 0652
PS I 0014 0656
0S-56 OS-57
ege,LAB PU&UCATIONS OPERA TING SYSTEM

MEMORY MANACEMENT .
h of th• following
schemes suffers from External Fragmentation?
[WBUT 2011 , 201 J(IT), 2018(IT)]
8 w11ic b) Paging
f Multiple Choice Type Questions_J · segmentation t tion d) All of these
a) d segmen a
c) page
1. Thrashing (WBUT 2007, 2014(CS) wer: (a)
• 2016(c 411
a) reduces page 1/0 , s to be larger than the amount of memory allocated to it, one
b) decreases the degree of multiprogramming S)) enable a process [WBUT 2011 , 2014(IT), 2017(IT)]
c) implies excessive page 1/0 9 d) Swapping
· r:se b) Paging c) Compaction
d) lmprov• the system performance can a) overlays
AJuwer: {c) ,o swer: (a)
nd [WBUT 2014(IT), 2016(IT) , 2017(IT)]
2. Which of the following is false? (WBUT 2007, 2014(CS), 20 1S(IT) iLB is a ki of b) interrupt c) cache d) main memory
a) Segmentation suffers from external fragmentation • 2019(cs)) 10. a) virtual memory
b) Paging suffers from internal fragmentation Aoswer: (c)
c) Virtual memory is used only in multi-user system
tation, if there are 64 segments, and the maximum segment size
d) Segmented memory can be paged
11. With a seg;:~ength of the logical address in bits is [WBUT 2015(IT)]
Answer: (c) iss12wo rd s,t b)14 c)15 d)16
a) 12
3. Which of the following page replacement algorithms suffers from Aoswer: (c)
anomaly?(WBUT 2007, 2012(CS), 2013(1T), 2014(CS), 2015(CS), 2017(CS) 8 elady's
. ·s used to solve the problem of [WBUT 2016(CS), 2018(IT)]
a) Optimal replacement b) LRU ' 20 19(CS)J
12, Compac~~~~:agmentation b) internal fragmentation
c) FIFO
Allswer: (c)
d) Both (a) and (c)
:l ~!~r(a) and (b) d) none of these
Answer: (a)
4. Variable partition memory allocation can lead to (WBUT 2008, 2009, 2o s(cs
1 .h mentation if there are 64 seg'ments and maximum segment size is 512
a) External fragmentation b) Internal fragmentation )}
13. :~t thsee~ength of bits in logical address is [WBUT 2016(IT)l
c) Both of these d) None of these d) 16
wora) 12 b) 15 c) 14
Answer: (a)
Answer: (b)
5. Virtual memory concept is supported by
a) demand paging (WBUT 2008, 2014(CS)J l4. A memory page containing a heavily used variable that was initialized ~ery
b) simple segmentation early and is in constant use is removed when ..... ...... page replacement algorithm
c) simple page allocation d) both (a) and (c)
Allswer: (d) is used. [WBUT 2016(IT)]
a) LRU b) LFU c) FIFO d) none of these
Answer: (c)
6. If a process has 32 k bytes logical address space and the page size is 2048 bytes
then the number of frames of that process is (WBUT 2009, 2019(CS)J
15. Which is the fastest of the following? [WBUT 2017(CS)l
a)4 b)8 c)16 d)32
Answer: (c) a) Cache memory b) RAM c) CD-ROM d) Register
Answer: (d)
7
· Page fault oc~rs when (WBUT 2009, 2015(CS), 2015(IT), 2017(CSJJ
a) the page 1n corrupted by application software 16. The mechanism that brings a page into memory only when it is needed, is
called [WBUT 2017(CS)l
b) the page is not in main memory
c) the page is in main memory a) Segmentation b) Fragmentation
d) one tries to divide a number by o c) Demand paging d) page and replacement
Answer; (b) Answer: (c)

0S-58
OS-59
f9PWA8 PtJBl,fCATIONS OPERATING SYSTEM

Page fault frequency In an operating system is reduced when [W


17 [: Short Answer Type Questions
· •) process.. tend to be of an equal ratio of the 1/O-bound and Cp BU, 201 8(
b) sin of pag.. is increased U-bound Cs))
c) locality of reference is applicable to the process . ·tterence between logical address and physical address?
d) proc...e• tend to be CPU-bound i , wr,at 1s di [WBUT 2003 , 2004, 2008, 2009 , 2016(IT), 2018(IT]

A ■swer: (c)
,4ns_wcr: ddresses are generated b~ the C'.U also refen:ed to as virtual addresse~. Phys ical
1.,og1cal a een by memory unit. Logical and physica l addresses are same m compil e
11. _ _ _ _ Is a high speed cache used to hold recently referenced
entriN a part of paged virtual memory. CWBU Page tab! addreSses ar~ ~· me address binding scheme; but they are diffe r in exec ution time address
12 ·rne and Joa I
a) Translation looks a side buffer b) Inverse page table 018(csij
c) Segmented page table d) Indexed page table ~inding scheme.
Aaswer: (a) . fragmentation? [WBUT 2007, 2008, 2014(CS)]
2. Wh~t 15 roblem of fragmentation and how can it be solved?
19. For 3 page frames, the following is the reference string : Whal 1s th8 p [WBUT 2007, 2008, 2016(IT)]
70120304230321201701
[WBUT 2018(cs
a)10 b)15 c)11 d) 12 )] Answer:
Aaswer: (d) 1'' part: t tion happened in a dynamic memory allocation system when many of the free
20. Which page replacement algorithm gives the lowest Page fa ult ra te?
fragrnenfathe memory space are too small to satisfy any request. Fragmentation are of
blocks o I
•) LRU b) FIFO cwe·u 2 1 t es: internal and externa . . . . . .
c) Optimal page replacement d) None of these T 0 8(1T)J tw0 y~I fragmentation can be solved with paging. Paging avoids the considerable
Answer: (a) E;:::m of fitting the varying sized memory chunks onto the backing store, from which
p t of the previous memory management schemes suffered.
21. ff there are 32 segments, each of size 1K, than the logica l address should have ;~~ther possible solution to the problem of external fragmentation is compa~tion, where
the goal is to shume the memory contents to place all free memory together in one large
a) 10 bits b) 14 bits c) 15 bits rv:,~~Tb1t°1S(IT)J
Answer: (c) s block.

22. In OMA transfer 2" d Part:


[WBUT 2019(CS)J
a) CPU is involved actively during data transfer The problem of fragmentation is as follows:
b) CPU is involved partially during data transfer In the worst situation, we could have a block of free (wasted) memory between every two
c) OMA controller is actively involved during data tran sfer processes. If all these memory were in one big free block, then we might be able to run
d) Both (b) and (c) several more processes. The selection of first-fit versus best-bit can affect the amount of
Answer: (a) fragmentation (first fit is better for some systems and best-bit is better for others).
Another factor is important that which end of a free block is allocated. No maner which
23. Page stealing is [WBUT 2019(CS)l algorithms are used, however, external fragmentation will be a problem. Dependrng on
a) a sign of efficient system the total amount of memory storage and the average process size, external fragmenta tion
,b) takfng larger space 's for pages paged out may be either a minor or a major problem. Another problem that arises \\-ith the multiple
c) taking page frames from other working sets
d) one of the tuning goals partition allocation scheme (internal fragmentation).
An~·er: (c) The problem of external fragmentation can be solved easily through compac11on. The
goal is to shuffie the memory contents to place all free memory together in one large
24. Where does swap space reside? [WBUT 2019(1T)l block but compaction is not always possible. Another possible rotation to the external
a) RAM b) ROM c) Disk d) Cache fragmentation problem is to permit the physical address space of a process to be
Answer: (c) nonco_ntiguous, thus allowing a process to be allocated physical memory whenever !he
latter 15 available. One way of implementing this so lution is th:oug~ the use of a paging
scheme. Paging avoids considerable problem of fitting the varying-s ized memory chunks
onto the backing store.

0S-60 OS-61
POPUURPVIY!'ATIOHI
OOk 500k ,OOk, 300k & 600k (In
~
r OPERATING SYSTEM

3. Given memory partition• of 1 ~t-flt aigorithms place proces~;der): Ho~ fit is used, the largest hol_e h~ been allocated to the requesting process.
each of th• fir1t-fit, beat-fit & wo ·thm makes the most efficient s of 212k ~<>u1~ . if worst- 212k is satisfied by placing ti on 600k block, 417k process is placed on
112k & 421k (in order)? Which algon [WBUT 2007, 201 2(CS), ~s e of llle~:11~,
13
r1oall~•,equesl of t l Zk is plac_ed on 300k block. But 426k process cannot be allocated in
OR, (IT), 20 1 s"'' 50, Uloek of 500k, as there ts no block large enough space to hold the request. The
I . Ul)j I c bl d rnernory I
ft t flt algorithm for memory aI ocat1on . ru, 11 d sire . . shown be ow. o
Compare beat flt an d l"I OR l••Bur 20 1he e 11ocauon IS 100 '7777....,....m'T7yj
, . • , 11 orYa 417k
f the First Fit Best Fit and Worst Ftt algorithms plac 01cf11 600 ~ - - - - ~
Id
How wou eac h o ' (. d ) Which I "th e Proc
of 212KB, 417KB, 112KB and 426KB tn or er . a ~on m makes th/''e, 800
efficient use of memory? [W UT 2014 (CS), 20 15 t1°s1
Aaswtr: . . . CS)J 1100
Consider the memo() partitions \\htcho1s shown below.
1nnl
1700
IOO 500 k (d)
60() OMl
soo 1--~......---1 ·thrn best fit is the most efficient algorithm for allocation of memory. This
300k the smallest possible hole.
1100 1he algort
600k method creates
(a-) - ~
1700 ..__
in Belady's anomaly.
4. eneflY expla [WBUT 2007, 2009, 2010, 2011, 2014(1T), 2017(CS), 2019(CS)]
Ln first fit, the first hole ,\ hich is large enough for use to satisfy the request so that
first process of212k is allocated the block of 500k. the i\Oswe~~ anomaly states that it_ is possible to have more page faults when increasing the
0
100 '77-r--m--Tn Belady frames while using FIFO method of frame management In computer
312k ICL'.....................'-"I no. of p~g~ormation is loaded in specific sized chunks. Each chunk is referred to as a
600 17TT"'"'~-rr.n 1
rnerno7, ~uires a frame for each page it can load. A page fault occurs when a page must
800 ~ - - - - - t page. dtdrefrom memory The following is an example of Belady's anomaly. Using 3 page
be loa e ·
frames, 9 page faults occur.
omeans Page request 32 032432 04

(b-) - . . . . J
1700 L.--- Page fault= 9 Frame I 0) 13 @ 00 044444
Frame 2 (:) 2 2G)J 3 3 lC)I I
Second process of 417k has been placed in the block of 600k, the third process of 112k G)11G)2222@
Frame 3
has been placed in the block of 200k and the last request which is 426k came in the
system, then the condition will not be satisfied since there is no block which is large s. Give details of how paging is implemented in hardware. Explain what a
enough to place it. Translation Lookaside Buffer (TLB) is and give details of how it works.
Th~ allocation is sh?wn in above figure. In best fit, the smallest hole, i.e., large enough to [WBUT 2008, 2010, 2014(CS)]
satJsfy the request 1s allocated so far. So, if the best fit is used 212k process which is OR,
allocat~d the block of 300k, 417k process has been placed in 500k, 112k process is What are TLB? Draw the diagram of paging hardware with TLB. [WBUT 2012(CS)]
OR,
placed m 200k block and finally, the 426k process is placed in 600k block. The memor'i [WBUT 2013(IT)]
allocation is shown below. or - - - - ~ · What is translation look aside buffer? Why is it used?
10() t77'.T'""m'TTr.l Answer:
600 ~~~~ I" Part:
Traditionally, support for paging has been handled by hardware. However recent designs
800
have implemented paging by closely integrating the hardware and operating system. The
1100 hardware support for paging is shown below.

1700 ~---....J
(c)

OS-62 OS-63
OPERATING SYSTEM
Ph)s1cal
address bl entries. When a logical addre
the page-ta de to the TLB. If the ss is generated by the CPU its page
w o f . esent page number is found its frame
fe t,er 1s pr . eble and 1.s used to acces number is
s memory, the whole task'
nuf11 ediatelYava~1~t would if an may take less than
unmapped memory reference were
1f11f11 tonger t~a th TLB a mem used. If the page
10'10 ory reference to the page table must
t,er is notin the
e '
frame numb er . be made known as
is obtained, we can use it to access
nufll • When memory,
, LBr,,11s~- this is shown be_lo_w_.._ _ ,
known
_ _ _ _ _--.
a5TLB h1~

Evcrv address generated by the CPU


is divided i~to tw~ parts: a page
page· offset (d). The page number is number p Physical Physical
The ~ ) and a
used a~ an ind_ex into a page table. address memory
contains the base address of each
page in ph~s1cal memory. This
combt.ned with the page offset to defin e the phys ical memory address base ~d~e table
that 1-
memory unit. The paging model of .
memory 1s shown be 1ow: s sentress 15
to the
0

Page 0
Page I
Page2

Page 3
o;
I
2
3
4
3
7
PageO

Page2

Page I
. ·rn temented in hardware as follows:
TLB15 1 ~ b represented as an array
i) It shou 1 . ea valid bit a virtual
TLB conta1 ns
number.
'
where each element of the array i.e.
page number, an M bit, an R bit
ry ·instruction generated by the CPU
each entry of
and a page frame

") Upon eve , the MMU will call TLB lookup, ifthe
Logical Page ;~ TLB entry for the virtua
l page should set Rand M bit and re
memory table 3 return the page frame.
What are the adva ntag es and
Page 3 6 disad vanta ges of having uneq
tixed partitioning scheme? ual size partit ions in
Pagi ng model Physical memory [WBUT 2009, 2015(1T)]
The page size is defined by the hardw Answer:
are. The size of a page is typically Theadva11 tages are: minimizes mem . .
The selection of power of 2 as a page a power of2 ory waste w1thm a part1t. 1on
.
size makes the translation of a logic Thedisadvantages are:
page number and a page offse t. If al address into a
the size of the logical address space Some queues may be empty, whereas
size is 2" addressing units, then the is 2"' and a page then queues are long. A preferable
hi gh-order m-n bits of a logical employ a single queue for all processes. approach is to
the page numbers, and the n low order address designale The number of partitions is predefined .
bits designate the page offset. and limits the total number of active .
Thus logical address is shown as: the system. Partition sizes are preset processes m
and small jobs do not nun efficiently
Page numb er .
page offset
Ip Id 7. Why are page sizes always powe
r of 2?
m- n [WBUT 2009, 2012(CS), 2013(CS),
2015(IT), 2016(IT), 2017(IT)]
Answer:
2"d Part: We know that paging is implement
ed by breaking up an addr~ss into
The TLB is associative high speed number. It is most efficient to break . a page 3:11d offset
memo ry. Each entry in the TLB consi The address into X page bits and Y
a key (or tag) and a value . When sts of two parts; than perform arithmetic on the addre o!Tset bits, rather
the associati ve memory is presented ss to calculate the page number and
item is compared with all keys simu with an item, the each bit position represents a powe offset. Because
ltaneously. If the item is found, r of 2, splitting an address between
value field is returned. Here the the correspoo<lmg page size that is a power of 2. bits results in a
search is fast, the hardware howe
Typically the number of entries in ver is expensived
the TLB is small often numbering
I 024. The TLB is used with page between 64 an
tables in the following way. The
TLB contains onl) 3
OS-64 OS-65
OPERATING SYSTEM
POPULAR PUBUCAT)QNS
ens. It retrieves the addresses of functions and variables contained
I. What Is thrashing? . Joading haptp those functions or access those variables and unload the library
(WBUT 2009, 2010, 2013(CS), 2013(1T}, 2014(1T), 2017(CS), 2on{IT)
J}11aJfl'IibrarY,
' e,..ecu e
, 20,au ,n tile ,mo!)'• . . .
OR. 20,s(c~· rro!Tl !Tl • ·o refers to the linkmg_tha_t is_done d~nng loa~ or run-time and not when
What . Thrahi""? What la th• cause of Thrashing?
• ·~
lWeu )J
... ic 1iokl g d In case of dynamic lmkmg the lmker while creating the exec. does
T~
Aaswer: . . S(ll)J n.o•"· · create · · l'nk t k· II h
v~ e'''· is rk. For the dynamic I er o wor it actua y as to load the libraries too.
'
Thrashing is 8 degenerate case that occurs \\hen there 1s insufficient memo th..,,01...,al wo II ed linking loader.
in the memocy hierarchy to properly contain · th · k.mg set required
. e wor · by thery uat one level
1" ., ca . . . .
"' re it is"' 50 . can be done at any pomt in program execution, but linking is performed
of the memory hierarch). This can result m the ov~rall performance of f:eer leveb ~:11 am_ic loat~~grarn loading only.
dropping to the speed of a Jo\\er level in the memory hierarchy. _Therefore, thrash·8Ystern 'the ttrlle o p
quickh reduce the perfonnance of the s)stem to the speed of main memory O 1ng can al
• r, Wors worst fit algorithm for memory management. What are its benefits?
the speed of the disk drive. . . . e Yet, the
1licre arc ~o prim:on: causes of thrashing: (I) 1nsuffic1ent memory at a oi ven . 10_~plain [WBUT 2013(CS), 2017(1T)]
-; xh.b. I 1· o• 1evet
mem<>r) hierarch), and (2) the pro~ does note I it oca ity ?f reference. If th~n ~,
insufficient memory to hold a \\orking set of pages or cache lines, then th re is ,4os"er: h the entire list largest block.
worst- fit scare 100
system is constantly replacing one block (cac he I.me or page) wnh · another. Ase rnern ory
the S)'Stem \\inds up operating at the speed of the slower memory in the hie a resu1~ 417

common e.xample occurs with virtual memory. A user may have several ap~ch~. A 83
running at the same time and the sum total of these program's working sets is gr~•cations 21 lK _ 600K Pos1uon 212 200
all of physical memory available to the program. As a result, as the operatingterthan 4I7K_ SOOK Pos1uon 417 300

~nches betv,een the app 1·1cat1ons
. .It has Io copy eac h app I'1cat1on
. ' s data to and frosystern d' I 12 K- 388K Pos,uon 112
and .,t may also ha'fe to cop) the cod e from d'1s k to memory. s·mce a context rn .Isk 212
. than . . d fr . switch 426 K_ 388K must wan 426 112
betv.een programs JS often much faster . retneVJ_ng ata om the disk, this slows~ 600
programs down by a tremendous factor since thrashing slo"ws the context switch down Process 276
the speed of swapping the applications to and from disk. to
MClllOf) Paruuons
If the program does not exhibit locality of reference and the lower memory subsystems
arc not fully associative, then thrashing can occur even if there is free memory at the The benefits is that the leftover block produced would be longer and potentially more
current level in the memory hierarchy. For example, suppose an eight kilobyte LI useful than that produced by the best fit approach.
caching system uses a direct-mapped cache with 16-byte cache lines (i.e., 512 cache
lines). If a program references data objects SK apart on each access then the system will 11, What is compaction? What are its overheads? [WBUT 2013(CS), 2016(1T)]
OR,
have to replace the same line in the cache over and over again with each access. This
Whal is compaction? What are the drawbacks of compaction? [WBUT 2018(1T)]
occurs even though the other 511 cache lines are currently unused.
Answer:
If insufficient memory is the cause of thrashing, an easy solution is to add more memory
I" Part:
(if possible, it is rather hard to add more Ll cache when the cache is on the same chip as Compaction is a technique to place all free memo!) together in one _lar~e block ~d to
the processor). Another alternative is to run fewer processes concurrently or modify the reduce external fragmentation. Compaction is possible onl} if relocauon 1s dynamic and
program so that it references less memory over a given time period. If lack of locality of
is done at execution time. This is shown below:
reference is causing the problem, then you should restructure your program and its dau
structures to make references local to one another.

9. What is dynamic loading? What is dynamic linking? [WBUT 2012(CS], 2013(lnTI1


How are they related? [WBUT 2013(1 1
Aimter:
Dynamic loading means loading the library into the memory during load or run time~
can be imagined to be similar to plugins, i.e., exec., can actually execute before
OS-67
OS-66
:~~.p:
POPULAR PUBLICATIONS

10~1·
SOK
P1
soi-.
,,lie
efflol')' r
OPERATING SYSTEM

esident, the pager will load _those pages into the RAM. The technique is
. g For its implementation, OS needs some hardware support
in f!ld deffland pagin .
,nentation and paging sometimes combined into one scheme?
.

QOK
. Wtl'I are seg [WBUT 201 S(lnJ
13
IOOK IOOK
Before After ,oswer:ation and paging are often combined in order to improve upon each other.
Compaction Compaction seginent ·ng is helpful when the page table becomes very large. A large contiguous
5eginented pagi ge table that is unused can be collapsed into a single segment table entry
Herc P. an~ p2 are the proc_esses occupied. O_the~ are holes ( ~)- Two holes h
5eetion of t e 1:ie address of zero. Paged segmentation handles the case of having very
compacted mto one hole of size SOK. Compaction 1s not always possible F can lit with a page tathat require a lot of time for allocation. By paging the segments we reduce
ents . . . •
to be able to execute in their new locations all addresses must be relocated. ~; Processes Joogse grn ry due to external fragmentation as well as simplify the allocation.
is static compaction cannot be done. relocation wasted memo
t of all passwords is kept within the operating system . Thus , if a user
z..: Part: 14- The ~ read this list password protection is no longer provided. Suggest a
11

Compaction is an overhead process because nothing else can be done until it is d ,nanages h:t will avoid this problem . What is Swap-In and Swap-Out?
arc Li!!!.ited to memory size. one. Jobs scheme t • [WBUT 201 S(ln]

Answer:
12. What ia virtual memory concept? [WBUT 2013(IT), 201 ◄(CS)J
How la it aupported and implemented? I'' Partt: the password internally so that they can only be accessed in coded form. The
CWBUT 2013(1T)J
Answer: Eocryp
only person with access or knowledge o f deco d"mg should be the system operator.
1st Part:
Virtual storage management is a technique that allows the execution of processe th 2'4 Part:
may not be completely in memory. In either words, it refers to the concept wher:b at It can be advantageous to remove processes from memory and thus reduce the degree of
process with a larger size than available memory can be loaded and executed by loal a multiprogramming. Later, the process can be reintroduced into memory, and its execution
the process i~ parts. The main advan~ge of this con~ept is that programs can be lar~:~ can be continued where it is left off. This scheme is called swapping. The process is
~ the physical memory. As w~II as 1~ abstracts main memory into an extremely large, swapped out and it is later swapped in, by the medium term scheduler. Swapping may be
uruform array of storage, separating logical memory from physical memory. Because of necessary to improve the process mix or because change in memory requirements has
this separation, the programmer needs to be aware of only the logical memory space overcommitted available memory, requiring memory to be freed up.
while the operating system maintains two or more levels of physical memory space. This
techniques frees programmers from concern over memory storage limitations. But the
concept of virtual management technique is not easy to implement and also may decrease
performance if it is used carelessly. Virtual memory is the separation of user logical
end
memory from physical memory. This separation allows an extremely large virtual
memory to be provided for programmers when only a smaller physical memory is
available. Virtual memory is commonly implemented by demand paging.

r" Part:
15· What is a multilevel paging? What
Virtual ~emory technique is implemented by Demand paging. When a process is is OMA? How does OMA increase system
concurrency? [WBUT 201 S(lnJ
swa~ped-m, the pager loads into the physical memory a set of its pages, which m~Y. be Answer:
predicted to be initially needed by the process The secondary memory holds retaining
pages of the process. Subsequently, when the p~ocess needs some pages that may not be Refer to Question No. 14 (a) & (c) of Long Answer Type Questions.

OS-68
OS-69
OPERATING SYSTEM
egpuW PUBLICATIONS

_[)lff9rent memory partitions of 15OK_, 820 K, 360 Kand 450 K (in th . ,-,sfl·er: .
11 8
.,. preeent. Explain how best flt algorithm can be used to place 91ve 11 1'' P'rt: sand disadvantages_ofpagmg:
a Proce,, Otd•r)
K. CWeur 201 of 31s ~i/Vantag~ external fragmentation. .
,Aaswer: 8(1l)J • N_ memory management algorithm.
1
1• part: • sunP \g is easy because of equal sized pages and page frame
• swapp1 ' .
150K 150K
tages ofpagi11g:
810K pi5adva~ternal fragmentation.
820K
: page table may consume more space.
c:=) 315K
vantages alld disadvantage~ of segme11tatio11:
360K
Ad No internal fragmentation
gment tables consume less memory than page tables (only one entry per actual
450K 450K 5
• egment as opposed to one entry per page in Paging method).
• ~ecause of the small segment table, memory reference is easy .
• • Lends itself to sharing data among processes.
• Lends itself to protection.
In best fit aJgorithm it will search nearer to 315k i.e. 360k. But in the worst fit algo . hrn, As the individual lines of a page do not form one logical unit, it is not possible to
the Jl5k will be fit in 820k. So memory space will be lost. So external fragmentatio~twill set a particular access right to a page.
Considerable compaction overhead is incurred in order to support dynamic
occur.
segment growth.
2~ Part: • There is difficulty in managing variable size segments on secondary storage.
Best fit searches the entire list of holes to find the smallest hole whose size is greater than • The maximum size of a segment is limited by the size of memory.
or equal to the siz.e of the process. • It is necessary to develop technical or constraints to present segment thrashing.
In situations where best fit finds an almost perfect match, the hole that remains is
virtually useless because it is so small. To prevent the creation of these useless holes, Disadvantages of segme11tation: .
worst fit works the opposite of best fit; it always picks the largest remaining holes. • Considerable compaction overhead is incurred in order to support dynamic
In first fit, the operating system looks at all sections of free memory compared to large or segment growth.
small holes. The process is allocated to the first hole found that is larger than the si_ze of • There is difficulty in managing variable size segments on secondary storage.
the process. Unless the size of the process matches the size of the hole, the hole continues • The maximum size ofa segment is limited by the size of memory. .
to exist, reduced by the size of the process. • It is necessary to develop technical or constraints to present segment thrashing.
nd
17. What is fragmentation? Explain different types of fragmentatio[WBUT 2019 (CS)l 2 part: nd
The logical address generated by the CPU is stored in a set of blocks known~ pages a
t
Answer: the physical address generated by the memory is stored in frames. In a paging syS em,
l 1t Part: Refer lo Question No. 2 ofShort Answer Type Questions. programs and data stored on disk are divided into equal, fixed sized blocks ctlled pages
and main memory is divided into blocks of the same site called frames. Exact Yone page
~ , T Questions. can fit in one frame.
2 Part: Refer lo Question No. 4(c) [F part/ of Long Answer ype
ntation? 19 · Write down the merits and demerits of a virtual memory 5 Y5t em[WBUT 2019(CS)]
18. What are the advantages and disadvantages of Paging and Seg~~ 1g(CS)l
What are the difference between a page and a frame? [WBUT

OS-71

OS-70
em>'WDllRLIGADOHl
OPERATING SYSI'EM
Answer: b locality of refere
u mean Y nce? [MODEL QUESTION]
Adv11ta&CS: ,t dO yo
. A\\ocating memory ·is d h' i,,w~.
.~· ._ft free ru1ckage is ok,easy an .c ip.
11. r\llY operating system can take ~0,~e.r,
. of reference
•p\e ofloca\lt)' t d while ca n~ state? as fol~ow~:
r
iii. Eliminates external ~ag . first one out of\' . executmg an mstruct\on . . .
men ISt I\ ke 111eP'.'"~\ddres~ gen~;r:ss m a process 1s likely to
iv. A\\ows demand paging tat1on . eps_ A 1og1ca f logical a
es generated during the previous few execut
be m
and
v. No need for considerati pre-pagmg . I' "(lilt)' O ed instructions of
on about fragmentation 10\I
P ocess.
DiYdvutage: weP1 xhibit good locality
processes e of reference?
i. Longer memory access {MODEL QUESTION]
times z4. ::~
ii. Inverted page tables mis mostly sequential in
0 nature since only 10-20%
iii. \ntemal fragmentation " \utioll of a ~rogr~hus the instructions are
next instruction to be
iv. Can be improved
using TLB E~~nch instruct1on .d •ns~ctio executed typically foll
b!GJ• I execute I n in the logical address space. ows the
v. Page table length reg ...vioUS Y Reference to non-scalar
ister to limit virtual memory p•• d to be in clo se pro . . f . ~ data,
x1m1ty o previous re1ere
size . e.g., arrays also sim
ten
ilar operations on severa nces because processes
10. Compare best flt and l elements of an array.
Answer: first fit algorithm for
memory allocation.
lWBUT
ten dto rnerform
. rin
Vint Fit: 2019(CS)l 2s. What ,s the P ciple of locality of reference?
ln the first fit approach is {MODEL QUESTION]
to allocate the first free par ,\nsw_er: f ality indica
can accommodate the pro tition or hole large tes that the logical addres
cess. lt finishes after finding O I s use
Principle octhat is in the
Advantagu: the first suitable free eno~~
Which current locality. Given this d in an instruction is likely to
• Fastest algorithm becaus Part1t1on. refer to a pa,:ults may not likelihood we can expect
e it searches as little as pos occ ur during operation that too
Disadvwagu: sible. manY_page present in of a process if pages in
\ocahty are me mo ry. Thus, one can expect its current
demand paged virtual me
• The remaining unused mem
ory systems to operate with reasonable levels of e ffi1c1· enc mory
smaller. Thus request for larg areas left aft.er allocation become w t •f. . y.
er memory requirement can
not be a as e 1'· it 1s too 26 ,What is dirty bit? Explain it in details .
Best Fit: ccomp ,shed. [MODEL QUESTION]
Answer:
The best fit d~ s with allocati In order to reduce the pag
ng e fault service time, a spe
ofth~ requestmg process. Thi the smallest free partition which meets the • associated with each page. Th cial bit called the dirty
s bit can
considers the s~a\\est hole thatalgorithm first searches the entire list of free ~(~~em modified (written into). Wh
e dirty bit is set to l by
the hardware whenever the be
actual process stz.e needed. is adequate. lt then tries to ent en we select a victim by page is
find a hole w/ h . n\sand \\e examine its dirty sit. lf using a page replacement
Advantages: 1c 1s c ose to it is set, that means the algorithm,
swapped in. ln this case we page
have to write that page into has been modified since it was
• ~: ~: ~~~:~~l:~~tuc dirty bit is reset, that means the backing store. However
that , if the
Disadvantages:
h better than first fit as it
searches the smallest free we do not have to write it into page has not been modi lied since it was swapped
the backing store. The cop in. So
Let the probability of a pag y in the backing store is
• lt is slower and may becomes e being dirty be 'd'. in this case, effectiv valid.
even ten d to fiI\ up memory e access time (eat)
21. What are internal fra with tiny useless holes. eat= p • (l- d) • swap_in
Answer: t . + d • ( swap_in + swap_out)
gmen atlon and ext
ernal fragmentation? + ( \ - p) • emat
Refer to Question N 4()
,ri
twBUT 2019(\T)\ ~!· A. de~and paging system takes
o, c 01 ong Answer Typ ~m~ u~i~s to replace a 100 time units to ser
vice a page fault and
e Questions. dir ty page. Memory 300
~~ ::; ~• • in brief: segme d;~~bih~ of a _p~ge fau access time is 11
1 lt is P. In case of a page fau time unit. The
ntation with paging. the '4 ~ a so P· it 1s observ lt, the probability of
a ue of P then? ed that the average page being
Refer to Question No. 13 twBUT 2019(\T)\ access time is 33 tim
of Short A Answer: e units. What is
[MODEL QUESTION]
nswer Type Questions . 3
P(P x 00+(\ - P) x\00)
+ (\- P)x l = 3P (P x30
0S-72 ~ P(3oop +\00 -\0 0P )+ l- P = 3 0 +(l - P) x 100) +(l - P)x
I= 3
⇒ P(300P + 100 - \00P) + \ - P =
3
OS-73
f2Pl,IW PVIPGADOH.S OPERATING SYSTEM

⇒ 200P: +99P-:! =0 to know that a page is dirty? [MODEL QUESTION]


After solving this Pi::. 0.0194 . itusefu 1
31, -~~ er: .
. k a clean page for replacement than a dirty page. The clean page can
If an 1nstrvctlon tak•• i microseconds and a page fault takes i\~s:hcaper to pdicd when it is replaced, whereas the dirty page must be written back to
21 . --ondl what will be the
effective Instruction time If on the an lddtt1 0 ttl 5sirnPIY d'scar e 1· ·11 '
mlc,....., , . averag n11 J I the page replacement po icy w1 pre1er to replace a clean pages over a
fault occurs ,very k ln1truct1on1. [MODEL Qu e • P• do . fherefore,
Es,1 Qe
Answer: . . . . ON] diS~·
Given. page fault service time= J and average memory access lime== ; dirlY page
[ Long Answer Type Questions
One page fault occurs every k instruction. Thus, page fault rate = ¼
. pping? What is its purpose? [WBUT 2008, 2014(CS)]
So, effective instruction time with page fault will be 1. a) What is swa

=(¼)x{i+ i}+(i-¼}{i} =i +i=i+f i\Os~er: es or segments of data in memory, swapping is a useful technique. That
To replace pag ter to execute programme and manipulates data files easier than main
enab1es aswapping
compu is particul3:1"lY use fiu1 ·tn mu It1progranu:nmg
· · environment
· · a roun d
with
29. A demand pagln~ system with. page table held _in regi~ters, takes 5 rnern~f)'- U- scheduling algorithm. When a quantum expires memory manager swap out
service a page fault: 1f ~mpty page 1s to be re~lace_d 1s not dirty. It takes rna to - robin CP hat J. ust finished & swap in another process to memory space that has been
15 the process t
the replaced page 1s dirty. Memory access time 1s 1 ms. Assume We rns of
effective access time 2 ms and that the page to b~ replaced is dirty 60% of ;h:nt an freed.
what it the approximate page fault rate to meet this access time requirement? time . the following sequence of memory references generated by a single
[MODEL QUESTION] b) consider . t .
·n a pure paging sys em.
Answer: program 1 , 10 4 170, 173, 177, 309, 245, 246,247,458, 364.
A demand paging system with page table held in registers takes S ms to service a 10 , ~1• 104 1
the no. of page faults for each of the following page replacement
Oet•r:"' 108
faull if empty page is available or if the page is to replaced is not dirty. It takes 15 pager ming three (3) page frames are available and all are initially empty.
. . . ms1 olic1es assu
the replaced page 1s dirty. Memory access lime 1s 1 m~. A~sume are want an effective ~he size of a page is 100 words:
access time 2 ms and that the page _to be rep~aced 1s _dirty 60:o of the time. The i)LRU
approximate page fault rate to meet this access time requirement 1s 0.01 %. Let the hit ii)FIFO
iii) Optimal page replacement [WBUT 2008, 2014(CS), 2019(CS)]
ratio for main memory =P, then desired time = Px main memory access time +(t- P)
Answer:
page fault time.
⇒ 2 = P x 1+(1-P){0.6x 1S+0.4 x S)x 10
3

⇒ 2 = P +(1-P)(9+2)xl0
3

3
P =(1/(1 Ix 10 )) = 0.01%

PF PF PF PF
30. When is the page considered dirty? When is the dirty bit cleared on a page? PF PF PF PF PF
[MODEL QUESTION] 364
247 458

~~~
Answer:
111 part: .
When the page is first written i.e., when the copy in memory does not match the version 458 458
on disk.
246 364
4
2• pa rt: . . . . . . . another PF PF PF
When the dtrty page 1s wnnen out agatn to disk 1.e., after 1t has been replaced by
page. Page fault for FIFO = 12
OS-74 OS-75
fQPl,!4'8 euaucATIOt!!J OPE RATIN G SYS TEM

p e offs et
Similarly for LR'-! =~ 2 • d
Page fault for opt1m replacement = 12
page 22
5 5
c) What Is effe etlv e mem ry acce ss time ? A pag ing
. _ sx4 ==2 7 byte s.
o sys tem with the tabl .-v requ ired - 2
111etT10•J
the memory. .....
I) If memory re,.r take s 20 0 ns, how
long doe s a p age
e ltorec1 111 50 , the s to the foll owi ng
ence d m emo ry eference pag es by a pro gra
. 7 8 7 1, 2, m,
take? d TLBs and 75% hit
is suc ces sful , w~a
tefere11c, 11 a1ven9r O 1, 8 , 1 , 8 , .' ' c~u r if 8 , 2 , 7 .
11) If we ad t 1s the effe ctiv e b) 0, • 'ge faul ts will 0 the p r ogr am has thre . I
refe rence time ("--
,_.u me that find ing pag e-ta ble entr y e (3) pag e fram es
the entry is there.) m the TLB s take ze 111 .., fl'lanY pa both
tlO" d FIF O rep ac 1 em ent stra teg y and LRUrep lace men t stra
ava 1lab e
OR, to t,~11101) 11 uses [WB UT 200 9, 201 S(C teg y?
1118 10 it • S) , 201 8(1T )]
I) Con side r a pag ing lWB Ul 2oo'a t gy in t he abo ve
syst em with the pag i iace men t st ra e per form s bet ter and
e tabl e stor ed a pag ii)Which reP why ?
ed m em o ry tefer11nc, {WB UT 200 9 , 201
:,k: . we add TLS . and 75 S(C S)]
Tl.Be wha t is the effe per cen t of all pag
e:ta ble refe renc es
ctive mem ory refe renc are foun d in
table Entr y in the TLB e tim~ ? (As sum e
s take s zero time , if t hat flnd in the 0
Aas wer : the entr y 1s ther e.) 7 7
CWBUT ~ a Page 2 2
Effective memory access 2 1 0 0 s• 8 7
time will be: 2(CS)] 9 9 9 9 8 8
i) 400 nanoseco~d; i.e., 200 9 7• 7 7 7 7
nano seconds to access 1• l 7 7 7
access the word m memory. the page tabl e and 200 I 2•
nanoseconds to ✓ ✓ ✓
2 2 2

it) Effective memory
reference time
= (.75 x 200 + .25 x 400)
nanoseconds LRU stratet?Y
= (150 + I 00) = 250 nano F rames I 0 9
seconds. 0 I 8 l 8 7 8 7 l
0 o• 0 0 0 8 8 8 8
2 s I 2 7
2. a) Con side r a syst 9• 8 8 I I
em with a 32-b it logi I 9 9 9 9 8 8 8
scheme, _4 byte pag e cal add ress spa ce, 9 9 9 9 9
t~bl e _entr ies, 1 kB a two -lev el pa in 2 1 1 2 2 2 2
::: i:f: ~:.a cce ss pag es a_nd a 4 entr I I 7 7 7
ttme 1s O ns, TLB acc y TLB . The page -t~bl ✓ ✓ X ✓ ✓
7 7 7 7
ess time is 1 O ns : X X ✓ 7
~1 How man y address
bits are nee ded for
and mem ory access :. Page faul t= 8
In this scheme FIFO is bett
X X ✓ ✓ ✓ Ix '>(

11) ~ow muc h mem ory the pag e offs et? er.
in byte s is requ ired
::v: ~m ory ? to stor e t he out er
pag e tabl e entirely 3. a) What are the two
in maj or diff ere nce s bet
[WB UT 200 9, 2015 b) What is inte rnal frag wee n seg me ntation
(CS)J men tati on? and pag ing ?
i)IK B= 2' 0 =~ Answer: [WB UT 200 9 , 20 1 S(C
Page size a) Segment is a logi cal S)]
size . Vis ible to the user
:. Page size = ~ = 222 Apage is a physical unit
invi sibl e to the use r
pro gram and is of arbi
trar y size .
2'0 Segment size can bec ome pro gram and is of fixe
eno rmo us pag ing has d size .
:. Pagesize = 222 bytes Segment need to sear ch the prob lem of inte rnal
for the pro per hole in frag men tatio n.
Page offset = 22bits In paging scheme, sinc e the mai n mem ory.
free slot. all pag es hav e the sam e
:. Page No = 32 - 22 = 10 size , it can plac e the
bits new pag e into any
\n segmentation, plac eme
l uses beS t fit., first
nt poli cy is sim ilar to
ii) The page no is further fit and wor st fit. vari able part itio ning
allo cati on.
offset. So the logical addr divided int0
ess . two equal parts, so 5 bit
for pag e no. and 5 bit ~llln internal frag men tatio
for n, the spa ce was ted
was:~t:t em o:Y may inte rnal to the allo cate
be slig htly long er than d mem ory regi ons .
mory inte rnal to a port requ este d mem ory; this
0S- 76 ion. size diff eren ce is

OS -77
fQPU\AB euet!fADOHI OPERATING SYSTEM

,. 1) What Is overlays? 2
[WBUT 010, 201 S(IT)
AIISWfl': . h problem of external fragmentation is compac
J~ f• rt .uon
. . '2017(C tion The goal is to
In onH11ting systems. an overla) is ,,hen a process
replace . to t e ontents so as to p1ace all free memory
..,...- • • ·I~ s itself with th s11 together .m one
. large blocks.
program . On Unix system. this accomp 1·is hed w1~
· h th cod
e exec( ) system ecall e of anoth
010
fhe s the rnernorYc
only wav to run new programs 1s to fork the running shuflle advantages and d"1sa dvantages
process and then · ln Uni)(, ct of single
. contiguous memory
pro~ on top of the child. This is known as the fork-ex 1• th
9 [WBUT 2010, 2015(1TI, 2017(CS))
ec technique. overlay then~~
511
di 11011 ,
b) Whit are th• advantages of segmentation
over paging? ,uoe1 .
[WBUT 2010, 2015(IT), 20 17(C ~os"'er, . .
S), 2019(" Ji/1'""1agt5· asily move a process dunng executi.on
Auwer: "SlJ " • 0 s cane lloW .
a process to grow over times
,4,1va1-,a: • os. can afast hardware: two spec1a. 1register
. an add and a compare.
• External fragmentation is eliminated • s,rnP1e,
• Allocation/De allocation of fo,ed size units such as
pages,
• can_ share code and data with otl1er registers tightly, is easier. pi5odv01110gesd: own hardware due to the add on every
so that only th . memory reference
pomoos are shared. • Slows
can't share me~o? ' (such as ~rogram text) ~tween
e desired process
• Can associate protection with critical segments •
without protecting other .items. sis still 1tm1ted to physical memory size
•• proces
Degree of multip~ogramming . .1s very r . d .
c) Explain th• difference 1m1te smce all memory of all active
between
intemal fragmentation a d
fragmentation. processes must fit tn memory
n
[WBUT 2010, 2015(IT), 2017(CS), 2018(IT) external • complicates memory management.
Which on• occurs in paging system? 2
[WBUT 2010, 2015(ITI, 2017(CS), 2018(IT) ' 019(CS)J Whal is the purpose of modify bit in pa~• table?
How the problem of external fragmentation 20 1
be solved? 5· a) •der the following page reference string:
' 9(CS)J b)ConSI 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7,
[WBUT 2010, 201 S(IT), 2017(CS), 2019(CS)] 0, 1
H many page faults would occur for the
following replacement algorithms?
A.nnver: ~~=urning 3 frames are available. Also assum
e that initially none of pages in main
111 Part:
External fragmentation hap~ns ~hen a dynamic memory.
memory allocation algorithm allocates (i} Optimal replacement, (ii) FIFO replacement.
some memory and ~ small piece 1s leftover that cannot [WBUT 2010 , 2014(1T), 2017(CS))
be effectively used. If too much
external fragment:it1on occ~rs, the amount of_u~able Answer:
a) The modi fy bit is set by the memory manage
memory is drastically reduced. Total ment hardware when there is a w11te -
memory space exists to sausfy a request, but 1t 1s not memory reference to that page. When a page is first
Internal fragmentation is the space wasted inside contiguous. loaded into memory, the modify or
of allocated memory blocks because of dirty bit is cleared . If the dirty bit for a page selected
restriction on the allowed sizes o_f al_locat_ed blocks_- for replacement is not set, the page
Allocated memory may be slightly has not been modified since it was loaded into memory
larger _than requested memory , this size difference . Only replaced pages that have
1s memory internal to a partition, but been modified need be written back out to the swappi
ng store.
not bemg used.
b) i) Optimal: 2 0 I 1 0 I
1 o 1 2 o 3 4 2 3 o J
2"4 Part: 2 1

~~ffim mm m
In paging. scheme, there is no external
fragmentation only have some internal

m m
fragmentation. Note that frames are allocated as units. If the memor
process do not happen to coincide with page bounda y requirement of a
ries, the last frame allocated may not
be completely fall. For example, if page size is
2048 bytes, a process of 72, 766 bytes Fauits=(i)@(D © (D © G) 0
~ould need 35 pages plus 1,086 bytes. It would
be allocated 36 frames, resulting an Page faults =09
internal fragmentation of 2048 - 1086 = 962 bytes.
In worst case, a process would nee~ n
pages plus I byte. It would be allocated n+l frames
resulting in an internal fragmentation
of almost an entire frame.
'

OS-78 0S-79
PQPUUR PUBLICATIONS
O PERATIN G SYSTEM

l, l
ii)FIFO :

' ,mm, ·mmm


optilll»I:

&&m m" mmmmmm @@


: :; ; : ! :
3 6

~~0 00© ©©0 ©0 @ @~ 1


~@)
• 15nos Page fau lt =8
occur? lWBUT 20 (1T
•· aJ u • what circumstances do page faults

m'. · , :rn:; '. !


12 for Six (6) Fram es:
system when a p age fauk 2 01ercs))
bJ DNcribe the actions taken by the operatin g LRU
2 3 6

e string: lWBUT 20 12(IT), occurs.


201e(cs))
cJ Consider the following page referenc
1, 2, 3, •• 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6.
followin g replace ment
How many page faults would occur for the
frames are in itially emptY~· 19°ritlirn
aaumln g four and alx frames respecti vely? All 8
• LRU replacement CD
• FIFO ,.placem ent ©
• Optimal replacement. Page fault = 7
Answer: lWBUT 2012(1T), 201S(IT)J EJFO:
that has not been brought • .
a) A page fault .occurs when an access to a page fa ul t. into ma,n
memory takes place. This situation is said to be page

b) The operating system verifies the memory access,

~=
'-- '--
u~ne ..
aborting the program if it · • .
lf it is valid, a free frame is located and VO is requeste
d to read the needed pag,s _invalid.
e into the
Upon complen·oo of VO, the process table and page table are updated and th e
ffi~illillW
@(i)( i)(i)(i )
mstrucr1on is restarted . Page fault= I0

.·i
Optimal
c) Reference string
12376)2)2)6
12342 15621 23763 2l236
For the frames:

l
LRO:
I , 2,

;@@ =. =@@@ ; -w- ·.


2 I 2 J 6

CD
Page fau lt = 7
Page fau lt =I0
g and a memory cons isting of 4
FIFO: 7. a) Cons ider the followin g page referenc e strin
frames : 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6
Find the number of page faults conside ring
i) FIFO pag e replace ment strateg y
ii) LRU page replace ment strateg y. .
Comment on the results obtaine d .
memory m_anage'!l en~ techniq ue?
b) What are the disadva ntages of segmen tation
segmen tation with paging is used?
How can these disadva ntages be avoided if
[WBUT 2013(CS) , 2017(IT)]

OS-80
OS-81
OPERATING SYSTEM
l!{lp,nAP OlllflfCA~
Frame No.

---rage No SegNo
? f-7''7"'-7'-,7"--7Lr'-,1
- 0 5
2
.-- I 7 Page 3 p,-,--,--,-,....,._-,1

8Ses · 0
~

- 3
2
II
9
table for 4 I'-._.~-,+-""'-'-!
seg -0 5
6 ----------i
14
-
~
Page No
0
SegNo
2
l~ r-r"'T""~.,.....,-r-,1 ~
Page fault= 1 5 z ~

oeet me· mem·m···


6 .2 I 2 3 7 6 3 2 I 3 II

8
6 I 4
t----=-----t g
2 6 seg - 1
Seg- 1 3 8 r-T"'T"".,,.......,-r-7-r,I f
•JUU,
Page No SegNo
. ·. Page fault = IO 0 · 12
Page

b) The disadvantages ofsegmenration in memory management technique are:


,) As with paging. this mapping requires two memory references per logical address. Thi
8Seg-2
I
2
3
13
14
17
table for 21
seg -2 221 - - - - - - - 1
23
~----~
slows the system by a factor of2. s
iJJ When the no. of segments is large, then the size of the segment table will also Logical address space
So, it cannot be accommodated in.any of the registers and has to be kept in memory. grow.
_ili) Segmentation is prone to external fragmenration . This may occur when all the blocks t · Direct Mem ory Access? How is it performed? What are its benefits?
in the memory are too small to accommodate a segment.
8. a) Wha ,s [WBUT 2013(CS), 2014(CS), 2017(IT)]
Both pagin~ and segmenration ~ave their advantages and disadvantages. So it is better to b A system has 8 physical frames. There are 7 processes in the system of which 4
) s have 2 pages each and 3 processes have 1 page each . The system uses
combme this two schemes to improve on each. This combined scheme is page the processe t
inverted page table. Find the total number of page ta bl e entries
· · th
in e sys em.
segments. Each segment in this scheme is divided into pages and each segment maintains Justify your answer.
a page mble. So, the logical address is added into 3 parts like segment number page [WBUT 2013(CS), 20~7(IT)]
number and the offset or displacement. This is shown below: Answer: .
' a) Refer to Question No. 14(a) of Long Answer Type Questions.

0S-82 OS-83
poeul,,AR PUBLICATIONS
OPERATING SYSTEM
b) Los1cal aJdrcs,

I
l'h)s1col lrome/oddrcs,
uestion No. 4(c) of Long Answer Type Questions.
PagrO
Pagr I
. JleJer to Q
Proccss I
.
Page Tobie z-' r•'1' Question No. 9 of Short Answer Type Questions.
. Jlefer to
PatieO
Paf!I
Since 4,2+J • I = 11
Page No are there Md also S
J" part• hat do you mean by ' Belady's Anomaly'?
ph) >1Cal frames are there,
I is TLB? W [WBUT 2O16(CS), 2O16(IT)]
Proces 2 b)Wtia
there are onl) one number o f
PsgeO page table entry ,n the wer: . No 4 & 5 of Short Answer Type Questions.
Page I S)stem using ln,crted page
t• hl.-
;.~ser to Questt0n .
Process J

::~
Process 4
Jlefi .
1 memory frames show the behavior of LRU and FIFO and
Having 3 phytc:ment algorithm for the page address string like 2, 3, 2, 1, 5, 2,
c) f,nal page rep ac
;psi 3, 2, s, 2.
[WBUT 2O16(CS), 2O16(IT)J

PaeeO
Process 5
; 0 ;wer:

:.'f.~l,sm5~,5,~ ~.•rn.rn.
Pa=O
Process 6
PageO
Process 7

t. a) What is 0~4? Describe the different type of OM~ Controllers.


m-§ §
b) What is thrashing? How can one detect the thrashing? [WBUT 20 s(cs
1
~r: )]

a~~~~ §·
a) 1• Part: Refer to Question No. U(a) ofLong Answer Type Questions. Optimal:

r'Part:
A simple DMA controller is a standard component in PCs and bus masterin g UO boards
for the PC usually contain their own high speed DMA hard"' are. Page fault = 6

b) Refer to Question No. 9 ofShort Answer Type Questions. LRU:

10. a) What is paging? Differentiate between internal and external fragmentations.


What is thrashing? [WBUT 2O16(CS), 2O16(IT)]
Auwcr:
1• Part:
Page fault = 7
Paging is a memo!') management technique that pennits a program memo!) (contiguoU.1)
to be non-contiguous into physical memory and thereby allowing a program _1~ ~ 11. Give memory partiti on of 1 OOK, SOOK, 2OOK , 3OOK and SOOK (in o rd e;;-
2
~;;
allocated ph)-sical memof} ,,here, er it is possible. T he physical is conceptuall) d1; •• would each of the first fit best fit and worst fit algori th m place pro~s_s t use of
into a number of fixed size blocks called as frames or page frames. The virtu al ad ~ th
417K, 112K and 426K (i n ~rde~)? Wh(ch algorithm ma~es _ e :~:~eet~~~tiguous
space or logical memory of a process is also broken into b locks of the same size called; memory? Compare the followmg matn memory organiza!ion ·th respect to the
memory allocation , pure segmentation and pure paging w,
pages. V.'here,er a program is to be executed its pages are loaded into an) frame fro~ or lollowing issues :
disks. page map table (P~fT) or simply page table ,,hich contains the starting ad~ressuiie (a) External fragmentation
base address of each page stored in physical memof) . If the no. of entries in Pt> IT 15 q (b) Internal fragmentation [WBUT 2O18(CS)]
small then registers can be used to reduce access time. (c) Ability to share code across processes

OS-8-' OS-85
OPERATING SYSTEM
egpuue PUBLICATIONS
e reference string will be
.uswer: rated pag
the gene I I I I611 J 161161 I •
1• Part: Rt/tr to Quation No. 3 of Short Answer Type Questions. So• 1416 . occurrences of the same reference are replaced by a single reference.
ecuuve . ·11 be
I:'. ence stnng w1
·" consa e re1er
~o,.,
2.. Part: . ..
Contiguous allocation with fixed sized part1t1ons does not suffi So· nevi rl1 6 I 6 I 6 I 6 1
· ·th · bl ·
fragmentation. but contiguous a11ocat10n_wi :van a e. s_1ze partitions does
er from exte
docs not suffer from external fragmentation, smce part1t1ons and pages · Pure Pa~ 6 6
~ntation does suffer from external fragmentation . are fixed in 81ng optir11a\
.. d fli X X
"""'"~ s1~

§~ rn
X
(a) Segmentation and Variable-sized parttt1ons o not su er from intern
.. . a1 frao-
since b, definition. a segment / part1tton 1s exactly as large as . b'11entati0
However, ·
• contiguous allocauon · · and paging both
· part1t1ons
· w1l· h ti xe d size it needs to be11,
Page fault= 3
tilled. . . . colllple1t1t
(b) Contiguous allocauon provides no support for code shanng. In seo.n .
. dd o• .. entat1on LRU: 6 6
as the segments of a process do not mix text an at.a, we can e . , as long

~ rn
1
tE
X X
beraeen processes. We simply adjust the segment tables of each pro~' Y share COde X

the segment of code in memory. ess. To P<lint to

12. What ia thrashing? How it can be prevented? What do you m


,.,.,_nee string? Suppose a process accesses the following ad;an by Page oD m Page fault=.3
particular time interval: resses ill a
0100, 0432, 0101, 0612, 0102, 0103, 0104, 0101 , 0611 , 0102, 0103, 0104 01
0101, 0102, 0609, 0102, 0105. o1 , 0601, I 51~ Part: . . .
Assume a page size= 100 bytes. The working set is the set of pages that are physically tn memory at any one lime. So
(1) What will be the reference string? the working set is a numbe~ of pag~s a pr~ce_ss demands to be loaded. from m~mory
(b) Considering the above page reference string , calculate the pag f during execution. If the entire working set 1s m memory, the process will run without
for the following algorithms: e au 1I rate causing many faults until it moves into another execution phase. If the available memory
(i) LRU replacement. is too small to hold the entire working set, the process will cause many page faults and
. (ii) Optimal replacement. Assume that number of frames= 3. run slowly since executing an instruction takes a few nanoseconds and reading in a page
Explain wortling aeta. What is its physical significance? [WBUT 2018(CS)l from the disk typically takes IO milliseconds. At a rate of one or two instructions per I0
Answer: milliseconds, it will take ages to finish.
1" & 2.,. Part: Refer to Question No. 9 of Short Answer Type Questions. Working set is discussed because the CPU will automatically store accessed memory in
3n1 Part: cache, close to the processor. The working set is a nice way to describe the memory you
want stored. If it is small enough, it can all fit in the cache and your algorithm will run
We ev~uate an algorithm by running it on a particular string of memory references and very fast. On the OS level, the kernel has to tell the CPU where to find the physical
computmg t~e number of page faults. The string of memory references is called a page memory your application is using (resolving virtual addresses) every time you access a
reference stnng.
new page (typically 4k in size) so also you want to avoid that hit as much as possible.
4,. Part:
Consider the Address sequence !3. Direct memory access is used for high-speed 1/0 devices in order to avoid
increasing the CPU's execution load. [WBUT 2019 (1T)]
OIOO, 0432, OIOI , 0612, 0102, 0103, 0104 0IOI 0611 0102 0103 0104 OIOI , 060I, a) How does the CPU interface with the device to coordinate the transfer?
0101 , 0102, 0609, 0102, 0105 ' ' ' ' ' '
b) How does the CPU know when the memory operations are complete? .
Since page size= Ioo bytes
c) The CPU is allowed to execute other program while the OM~ controller 15
T: reference in the reference string is obtained by dividing (integer division) each transferring data. Does this process interface with the execution of th e user
a ress reference by the page size i.e., I00 bytes. program . If so, describe what forms of interference are caused?

0S-86 OS-87
MJW pYBLICATIONS OPERATING SYSTEM

. e we trap to the operating system indicating that the logical


Answerde: . ntroller transfers an entire block of data directly to or fro . . therw1s
1irn1t; 0
f h h . I . .
beyond the end o t e P ys1ca memory segment. This 1s shown
a) The vice co . b h CPU T . . . rn its ... and tne_ atternpts
• o in1t1ate a DI\A • 0 "'n bu""
storage to memorv .,, with no intervention. hYt e . . t 'Yl.r\ tran " 11er addressing s{
CPU first sets up the OMA registers, wh1c contam a poin er to the source of a tSier, "lne
i,c!01~· t-:-L-1m-1,t _B_
as-;
e
pointer to the destination of the transfer and a counter of the number of b ransfer, a
trans ~e-.1 Then the OMA controller proceeds to place addressed on the b Ytes to b
while the CPU. is available to accomp 1·1s h other wor k.
" 111;\L
transfers us to Perfornie
Segment table

b) One intemipt is generated per block to tell the device driver. That the Physical
completed, i.e. The OMA controller .mterrupts th e CPU . operati on has Memory

c) Yes. Once OMA processes are done, an interrupt is generated which adds
· the sequence of queuing
processes lead. Thus affecting · process. so the rn a1n. NO
Trap; addressing error
14. Write short notes on the following:
a) OMA and its utility (WBUT 2008, 2012(CS)
03 c) Multi l_e"e~J~;:~::ge memory r~q~ire~ents of page tables is ~o use ~ultilevel paging.
b) Segmentation
[WBUT 2012(1T), 2O16(CS), ; ;1 J:l11 The solutton d irtual address is d1v1ded into three or more sections, with all but the last
c) Multi level paging
lWBUT 201 )] In this me~ho a\ numbers in different page table, and the last one being the offset. 1n
d) Belady's Anomaly
e) Hierarchical page table [WBUT 2015(CS), 201 1~~ !~ section bemg _pag the first section is the page number in a top level page table and is used
f) External Fragmentation & Internal Fragmentation [WBUT 201 S(IT)] two-level pag,n~ond level page table. The second sections is the page number in the
Answer: [WBUT 2016(1T)] 10 look up atseble and is used to look up the physical
. b
second leYe1 a page num er.
.•) DMA & its utility:
OMA is a technique which used t? transfer data between memory and l/0 devices with d) Belady's Anomaly: Refer to Question No. 4 of Short Answer Type Questions.
less effort on behalf of the operatmg system. The DMA unit has access to the data b
e) Hierarchical page table. . .
~ can transfer data ~utonomously in and out of memory. ln practice, a program wou~~ Hierarchical page tables break up the logical address space into multiple page tables. A
t~ct the D~ urut to, say, ~ransfer a specified block of data from memory to a simple technique is a two level page table.
penpheral devt~. The D~ urut operates _by suspending the CPU and accessing the
Example: . . . . .
memory system itself to obtam the data required. This technique is called Cycle stealing, Alogical address (on 32-bit machine with 4k page S1Ze) 1s d1v1ded into
because machine cycles are effectively stolen from the CPU and used by the DMA unit to i) a page number consisting of 20 bits
transfer data alon? the data bus. Note that, DMA is not an interrupt; the current
1 ii) a page offset consisting of 12 bits. . . . .
program s context 1s not saved and the CPU does not do something else. Since the page table is paged, the page number is further d1v1ded mto a 10 bit page
b) Segmentation: number and a t Obit offset. Thus, a logical address is as
Page number PagcO!Tscl
Generally a user prefers to view system memory as a collection of variable-sized P, d
segments rather than a linear array of words. Segmentation is a memory management
scheme that supports the user view of memory. A logical address space is a collection of
10 10 . .
segments. Each segment has a name and a length. Each address specify both segment Where P, is an index into the outer page table and P2 is the displacement Wtlhm th e page
:me and ~he offset. We ~ow define a mechanism to map two-dimensional user-defined of the outer page table.
tab~~es1;~o one-dimension~l physical addresses, and is done in form of the segment
· _gical address consists of a segment number S and an offset d. The segment
number S tsbused as an index into the segment table Each entry in the segment table has
a segment ase which ·
.h · ' the ph points
h . · r it
whtc points where · alw ere the physical memory begins and a segment imn0
st
Y c memory ends. Therefore, the offset d must be betwee

0S-88 OS-89
OPERATING SYSTEM
f9N,N ' PVffYCATIONS

Two km pa,e table:

-
INP UT / OUTPUT HARDWARE
[ Multi ple Choic e Type Quest ions

[WBUT 20013(CS)]
erally done in terms of
Disl< 1/0 gen b) bytes c) blocks d) bits
1, a) sectors
.4oswer: (c)
opening or creating a file?
h of the follow ing system call is used for 2019(I nJ
[WBUT
2, WhiC c) Open d) Close
b) Write
a) Rea d
,.tDswer: (c)
Page table memory [ Short Answ er Type Quest ions

f) Emru l Fragmentation & Intern al Fragm entatio


n:
ntiate between Blocking vs. Non-B locking input-output. [WBUT 2013(CS)]
·tt OR,
No. -l(c) ofLong Answe r Type Quest ions. 1. Dr ere
hfu lo Q11ation [WBUT 2017(InJ
g input-output.
Differentiate between Blocking Non-Blockin
AJJswer: .
Blocking- Here, process suspended _un_tII 1/0 ~ompleted.
It is easy to use and under~tand. It 1s msuffic
1ent for some needs Nonblocking- Here VO
call returns as much as available.
, 11 is implemented via multithreading
• It returns quickly with count of bytes read
or written.

and an interrupt? What is the use of each


2. What are the difference between a trap [WBUT 2016(CS)]
function ?
Answer:
I" Part:
, and causes the CPU to stop what it is
An interrupt is generall y initiated by an 1/0 device routine, complete it,
interrupt service
doing, save its context, jump to the appropriate
restore the context, and continue execution.
A trap is usually initiated by the CPU hardwa
re. Whenever the trap condition occurs, the
jumps lo the appropriate trap routine,
CPU stops what it is doing, saves the context,
e it, restores the context and continue execution.
complet
2"d Part:
the processor to execute some service
Interrupt are used for external devices to signal
code.
n the user code and the operating
Traps are used both for control transformation betwee . .
handling. .
system via system calls and for error
t service routine, which is then
The CPU uses this to get the serial device interrup
executes as

OS-90 OS-91
OPERA TING SYSTEM
m"! Meueu<fADONS
__ .. --'ware interrupts, while traps are software invoked interr
lntemJPIS .. ~ 11111u 'ft II
FILE MANACEMENT
. Upts
,"'8~ the tem1 trap refers spect tea y to an interrupt intend d ·
In some ..._-- . e to i .•
conrext s"itch to a morutor program. n11iates a [ Multiple Choice Type Questions

[ Lon& Answer Type Questions J t ctured directory, the series of directory names that culminates in a
a tre~;~;:erred to as the
111 [WBUT 2016(1T)]
1 1
1. Write I short note on Blocking and Non-blocking 110. CWBur fiie na111 8 name b) Working Directory
2 h
a) pal bolic name d) None of these
AIISftr: · 013(11))
With blocking 1/0, 8 process is moved to the wait queue when an l/0 request is c) 5y111
moved back to the ready queue when the request completes, allowing oth rnade and ,oswer: (a)
nnn in the machine. er Process to [ Short Answer Type Questions
With non-blocking UO, the 1/0 request returns immediately, whether the
operation has occurred or_ n~t _This allows the process to check for availabl:~~uest ~d Vo . with diagram different File Allocation methods. [WBUT 2014(CS)J
getting hung completely 1f 1t 1s not there. One approach for programmers t _ta Without 1. Explain disk has size 128 GB, and blocks are of size 64 KB. If all block numbers
non-blocking 1/0 is to have a multithread application, in which one
1 ltnplernent
bloclcing l/0 calls, while other threads continue to update the screen or e~ad fllakes
i suppose; as 4-byte integers, how large must a main-memory file-allocation table
are store
(FAT) be?
tasks. Two 1/0 methods are shown below. p orrn other Answer:
Kernel
rtqucshng process
requesting process
fh~ main problem in file management 1s· how to allocate space for files so that disk space
user user 0
/~tilized effectively and files can be accessed quickly. Three major methods of
device dnver allocating disk space are:
• Contiguous Allocation
lntC/TUJ)t handler Interrupt handler
Kernel • Linked Allocation
• Indexed Allocation.
Each method has its advantages and disadvantages. Accordingly, some systems support
all three (e.g. Data General's RDOS). More commonly, a system will use one particular
Time- Time-+ method for all files .
a) S}nchronous IIO b) Asynchronous 1/0 In contiguous allocation each file occupies a set of consecutive addresses on disk and
each directory entry contains file name, starting address of the first block, length in
2. Write short note on Data transfer method of 1/0 devices. [WBUT 2019(CS)]
Aaswer: blocks etc. It has usual dynamic storage application problem.
e.g.,
!)atal transd fer between CPU and the 1/0 devices may be done in different modes Steps Only starting location and length (no of blocks) is required.
mvo ve are: ·
For ex.ample, a disk consisting of I kb blocks, a 100 kb file would be allocated in
• Buffer the byte into the buffer.
100 consecutive blocks. With 2 kb blocks, it would be allocated 50 consecutive blocks.
• Infonn the CPU that the device · has the I byte to transfer (i.e. bus grant request)
• Transfer the byte (at system bus speed)
• Replace the control often bus back to CPU. Fig. shows-
Bus Request BR AB Address Bus
DB Data Bus

RD Read
Bus Grant BG w Wnte

OS-93
0S-92
fQP!ftAP PU@l1c;ADQNS OPERA TING SYSTEM

., agts: have lO be specified. No external fragmentation.


1
4/t'il'.' does not
COIIIII Dirttto ',1,s1zc ts·
File SIJlrt f ~,dt•a/lfa~en;ial access efficiently and is not for direct access. Each block contains a
Count 0 Pdoes seq . space. Blocks scatter everywhere and a large number of disk seeks may
t. 14 11 wasting
mail 19 ..ainter,
lost 28 r· neeessaf)'•
6 i,e fon method of disk space
mail
Jodeted alloc~;n solves the external fragmentation and size declaration problems of
LinJ.:ed aJloc~Jocation. However, in the absence of a FAT, linked allocation cannot
lis1
contiguou~ \nt direct access, since the pointers to the blocks are scattered with the
suPI'°.rt e ics~Jves all over, the disk and musk be retrieved in order. Indexed allocation
bl0C ~ this .
· · a 11 th ~ p~tnters
themproblem by bringing toget her .mto one location i.e. index block
solve~le has its own index ~\~ck, which ts an array o~ disk block addresses. The i"' entry
1 b
It is suitable for sequential files. The difficulty is that it is not su·t each . d block points to I block of the file. The directory contains the address of the
contiguous free blocks in the disk. Other problem is external fragrn a le to find the . the in ex
entation - Which :~deX block shown below.
means that some free blocks could happen between two files.
It complicates ·mapping around" the bad block, which can also continue · fr
by breaking the contiguity of disk areas. Moreover, the method is tn a~enta1ion 84
impJement as contiguous chunk of space is avoidable easily. very simple 10 CJ
6
Liabd file allocation technique: 816
~th ~e linked ~location approach, disk bl?cks of a file are chained together wi th ~...i;d----f;d--~~ l).,.._J
llnked !ISL The duectory entry of a file contains a pointer to the first block 0 d . a 20
CJ
to the last block. To create a file, we create a new directory entry and th/ _a pointer 24
CJ
initialized to nil. When a write occurs, a new disk block is allocated and ch~t_omdters are 28 29
end of the list ne to the CJ CJ
Directory th
To find and read the ith block, we use the pointer in the i index bloc!,,. entry. This scheme
File name Start block length is similar to the paging scheme. When the file is created, all pointers in the index bloc!,,.
are set to nil. When the ith block is first written, a block is obtained from the free space
File B Last manager, and its address is put in the i'h index block entry. lndex allocation supports
block
direct access without suffering from external fragmentation . Index allocation does suffer
from wasted space, however.

2•d Part:
The number of table entries is 128 GB divided by 64 KB, and each takes 4 bytes. Thus
th e amount of main memory space required by the FAT is 4x2 = 8MB
1
2· Describe structure of FAT file system. [WBUT 20 B(IT)]
t Answer:
File blocks are chained in a linked list. The directory entry has pointers to the firS and File Al~ocation Table (FAT) file system is a simple file system originally designed for
th
last file blocks. Append is difficult to do without the last pointer. small _disks and simple folder structures. The FAT file system is named for its me od of
h
organization. The file allocation table, which resides at the beginning ofl e volume.
OS-95
OS-94
PQPUl,AR PUBLICATIONS
OPERATIXG SYSID.t
Stnd9rt of FAT fik ~-sttm:
Th( fig. ~O\\ illustrates ho\\ the FAT file s~stem orgamzes a, olume. • effi ct·ent unless the .entire vector is kept in main memorv• • Another approac h
..-< art 111 gement is to hnk together all the free disk blocks Keep" -
FAT:: ,t--11,11·· ce rnana ·a1 i . th d" k · mg a potDttr
PlrtitioaBoot HTl Root folder ff(( sP3 block in a spect ocat1on on e is and caching it in memorv The Ii1
~"10{
du licate to .i., first~ painter to the ne:\1 free disk block and so on.
tt'u~ taJf\) a . · heme~LS
_ Ho\\ever, thi;., sc
~c<t :o~ r to cra-.erse the ltst \\e n:ius: read each block \\hich requires substantial UO
l. Explain what is Indexed Allocation of file space on disk. Wh i ewc 1en · . craversing the free hst 1s not a frequent action.
actvantages and cf.advantages of contiguous allocation? tw8 at •!l c,. f0(1Ullste) 1•
lJl 20,S\~~
Aaswer. tit'' ·hi-node cont~ 13 block points i.e .• 10 direct - I single indirect -1 double
1•Put: ~) 5 ~~ e.11. "pie indirect pointer
LirRd al ocarioo ~,es n-.',( :s-uppun 1"3Djom access of fites. since each bl ,. :,:,,,,e,.•1-1 01
fOIDi fr.xn lhe ~,iros inde'.'.ed sllocaticn soh es this problem b,
=-.1 I. nn~
r.K
~1 OQ!
-~
~ c s ~ .m!.'.' !.Tl u,ue..'\ 1..; 01:11,..

"' ., a!.]
1~inter: first 10 pointers pomt to a d:m bloct- (each 512 b)tes) of a file. i e., 51 :,.:10
l . -
t"'-Put "' 51 :o t~1es.
Ad\~
• &~ ~ S..""-.7lera!l ~ ci..~t _cces.ses are suppor.ed b~ this. ~~:iile is btg,,~r than ~0 blocks _(5120 b~~es). the 111:. poi;;r_e;s poir.:5 ;o a srn~e
• 1li5 is ~~ ~7 ::,· ~e the nl!:Ilber of seeks are mini."llal · _~_.. ,. ,oc;__ 1,hich conums.128 pointers to LS more dz1ll ;ilocks ie,
roKC;:,>..-v.!5 !lloc<>..Jioo of file illoc'\-5. ~\,lo-~ Ct.

~=0-5.,2 52
\ : size of a pointe; is.! bytes)
Dmchu.~
• r·, ~ S'.'.iie-r ~ ~ ~ !a.1 eXie..cl fragmentation. r. ·. -- =~· : J-65536= ,0.656
~ : C!!l ;port files upto 70,656 b~~es. lf .be file is bigge- ~ u1e i:• x,m1e· :ioi..:s
c:-Gi::i~ i::; r=.s o; mema,: miliz:cion. ~ qk::, 5

• ~ ,- ~ ii:e size ts .£ifi..-.:,:. b,eQ_~ i~ depend5 on the 3.\


~ ! ~OU~ e mdi:ect block. ,,hich concins 1:s po·-~e;<,; to 1:s wO.'"e ::.·-g. e ·-:i..--ec.
.u::.i§:X<l!!S - ~ . '!l?. ;:z-·~w b~ce. -~

Long Answer Type Questions


1. a) Briefly explain cfr:fferent free space management techniques.
[WBUT 2010, 2-:·L~ ·t:'.i "'e is ;:.gger ih2n t..at. the 13 pointer ?()in::s a!::-: e in£-ec. .:Joc:e.. 111-·: -

b} If~ sa.e_of each dm bock. i s 512 bytes in Unix file system , assum·~g t::<~ ro::a...s i:s ;ic.:::.m to es mored~ e in.:lL'"ect ~ ods ~ Step 4 \\ c>e
cl a pomta- IS • bytes. f"md the maximum s ize of a ftle wnen !node bloc.; cc·::...."S ,:,,·9~051: 512 51: -.~_
10 dinc:t pointers. 1 singe indirect potnter, 1 oouble indlrec: po n,er a"0 t ::-:-1 =~~ -~--;-x-;-x-;--)
indirect pail:af. f.'IBUT 20~0, 2-:' L,...,
=$45926!- lOHi! 18::!
AJlswff:
•)'Free~ i?"""~em is? t~--~'.le to ae-.se tne sp?Ce from delete,: files =1,as::.::01.oss b11es
- 5. if ~ e 10 ~ C"?-: of tee cisk s~. trK S\'Ster.l m.aintains a ~ ~
foe ~ ~ list ~ a.. free 8Si: - oo'l3 "u-e-) ~ file is delete<i its ask s;r. '- a) 'Nh.at are the advantages and d sad,antages of I nk eo file Alloution
~tl)~~~lis.. "t-ennique?
: How does Indexed file Allocation Technique o.ercome trie a.t,ove
f ~ , t a = ~ ~ tis. is· - ~ as a bit map o· bit ,ecwr. rz:- · :d ~,antages? fHBlIT 2013;CS 2017{IT}}
11
~ ~ I 6- If •. - • is f.--ee ~ ·:tis I ~ if the ;,Joe is all~ LJ;: \tsw'T:
O.for~½ ~::eaci:~b.ae-:-e·od:s? 3 ! ~ 8 9 to 11P131·.1s,::.:
z:XJ : - ~ tree ?:"A'lu.e res1afcr~ ~ 2:e ~ ~ ~~ r.; .; ·; :.:.;. · 1
~aga:
>; ene:-..ai f.~g;;ientaliou v.itn lim-ed " ~ -..
00111100tll 1110)!)ll&XOO')lllOOOlO ..... foe ~ ~- arl" mtL~ of t:'.is ~~
•• f:ec ~ od;. ca;;i oe llSeC: to sa-~ ~ rec-~
~st:::;:~ ~i:tsd,:~ ·- -_.,._Efree -ocksooL_.; ci.s... U.,.,~.
OS-96 os.9~
OPERATING SYSfEM

iii) There is 00 need to declare the siu of a file when that fil e is created.
iv) A file an continue to grow as long as there are free blocks.
~,ages:_ lernent
) ~aSY 10 ,rn~ fragmentation
• r,1o externa •iy grown with the limit of the array size.
D_,,._-,a: • . eS can be eas1
i) h is inefficient to support direct access. • Fil dorn access.
fast ran
ii) It is effccti~e only for sequential access files.
iii) Loss reliabilit) . es·
f)
jsadvan/ag .e overhead (index)
e spac
b) The indexed file allocation method is the solution to the problem of bo • J..,afg ential
access may be slow.
th , sequ t contiguous block for fast access.
and linked allocation. This is done by bri nging all the pointers together i t cont1&\lo
called the index block. It sup!'°rts d,rect access .i.e. th e "th · °
n one I 111
I entry m the index bl Ocatioii
• Must alloca e
to the ~ sector of the file. It 1s reliable Any free block anywhere on the disk rnOck Poillts fil structure and directory structure. Discuss various techniques for
1
a request for more space. ay satis~ 4, Discus~ ~mentation . Discuss the file allocation methods. [WBUT 2019(1T)]
direetor'Y imP
.4-nswer:
3. What is I record in a file? For a file having multiple records h
dttr.rent indexing strategies there? Explain each strategy very brieflt ~t ire u,1 111 part: refers to logical structuring of the record determined by the sequence iP
advantages and disadvantages.
1th Fil: structure e accessed. Logical definition of a file is that it is a set of logical records fl.
[WBUT 20 16 (C;) relitN,
A1mm: • 2016(1l)] which lhe~ ~orage space on a disk in terms of physical blocks. Normally, the block size
1" Part: !s alloca~ b~es. All basic read/write operations are in terms of blocks. In a directory
51
Records in file are ~e up with field, each of wh ich contains one item ofinforrnat' 1s of directory groups the files owned by a user. It contains information about files
set of records ~nsututes a file . For example, a personal file contains records s~on. A struct;e, .a central to the functioning of the file system. It contains information like file
name, address, pm code, phone no, etc. ch a, and_bt us \s location and its ownership. It can be vie\\ed as a symbol table that translates
attn utes, . . .
I.he filenames into their directory entnes.
2~ Part:

.J===3==8
File has array of pointers (index) to block.
2' 4 part:
Allocate block pointers contiguously to metadata
Root d ircclory
and must set max length when file created. Allocate
pointers at creation, allocate blocks on demand.
Maintain multiple tests of block pointers and last
,,..""ES LJ DtrcclOI)
entry points to next block of pointers.
ladex aUocation example_ : _ _ __
D Df., !o Or,
A hierarchical directories are shown. All directory and subdirectory entries are shown.
which define the totality of system files . This is a better way to organize files. Directories
are stored on disks, so the efficiency of directory operations is affected by the number of
d!sk accessed required to complete a search, to append or re~ove an entlJ'.· H~nce
directories are organized in a way that minimize the search, addition and deletion ume.
Various system calls are used for directory implementation like create a file where a

OS-99
OS-98
POPULAR euaucATIONS OPERA TING SYSTEM
. d in the directory, list directory knows the list
corresponding coif) is ma ~ reading a directory it should be closed Di of files in anagement technique (any one) of disk:
directory, close director)', a er . rectories ca the ee-space~ No. J(a) of Long Answer Type Questions.
n be b) f r Quest10n
renamed. ,/tf (O
1tr t' n method of disk space:
I 1" . .
3~ part: Refer to Question No. 1(1'' Part) of Short Answer Type Questio11s. 11 11oca ,o
I0de•edti Ocauon• olves the extema ragmentat1onf and size declaration problems of
c) s · th b ·
.
Lin ked a t'
alloca I •on However, •
10
he a sence
. o ah FAT, linked allocation cannot
5. Write ahort not•• on th• following:
tiguous . since t de pointers
direct access, d' to t e blocks are scattered with the
con flic1ent k kb . .
1) Unked file allocation technlq;BUT 2009, 2012(C~), 2013(IT), 2018(CS) m order. Indexed allocation
su rt he mse Ives all over, .the 111s h an .mus e retneved
Pp<> h .
b) f,....pace m1n1gem1nt technique (any one) of disk twBur 2~~8(1T)J
2 bloCkS t _e bl m by bringing a t e pointers toget er tnto one location i.e. index block
c) Indexed allocation method of diak apace [WBUT twBur 201!lll)1 5otves this pr? 0e wn index block, which is an array of disk block addresses. The i"' entry
th
d) /-node 2016(CS), 2018(11~1 each file. dex:,ts
has u oc k points to i block of the file. The directory contains the address of the
Auwtr: ,,1 ,n the ,n ck shown below. . . ·ih •
•) Liaked file allocation technique: . . index blo d the iih block, we use the pointer tn the I tndex block entry. This scheme
With th l"nked allocation approach, disk blocks of a file are chained togeth . ·
d and rea paging scheme. When t he filI e ·1s created, all pomters · ·
To fin_ th m the index block
' e IThe directory entry of a file contains
• • With a
to the fi1rst block and era P<li
linked list a po1~ter is similar t~I ~en the iih block is first written, a block is obtained from the free space
h
to the last block. To create a file, we create a ~ew d1rec~ory entry and the Pointers nter are set to ni d its address is put in the i' index block entry. Index allocation supports
initialized to nil When a write occurs, a new disk block 1s allocated and chained are manager, an
. ct access without suffering from external fragmentation . Index allocation does suffer
end of the lisl · to the dire t d space however.
Directory
from was e '

0 File name Start block length


c:=i
s
c:=i
...
s 2 Las1
D
0

10 File B 4
c:=i block D
IS 8
c:=i D
20 12
c:=i D
25 16
c:=i Wd:11-t=--t::::t-"t'{4~ ,,.-~
30 31 32 33 34 20
c:=i c:=i c:=i [=:J C3 D
24
D
28
D
File blocks are chained in a linked list. The directory entry has pointers to the first and
last file blocks. Append is difficult to do without the last pointer.
d) i-node:
Advantagts:
File size does not have to be specified. No external fragmentation . An i-node is a data structure on a fil e system on UNUX and other UNIX like operating
systems that stores all the information about a fil e except its name and its actual data
Disadvan1agts: ~en a file is created, it is assigned both a name and an i-node number, which is an
It does sequential access efficiently and is not for direct access. Each block contains a integer
1
that is unique within the fi le system. Both the file names and their corresponding
pointer, wasting space. Blocks scatter everywhere and a large number of disk seeks may ·node numbers are stored as entries in the directory that appears to the user to contain the
be necessary. files. i.e. the directory associates fil e names wi th i-nodes. Whenever a user or a program
'.efers
1
to a file by name, the operating system uses that name to look up the corresponding
·node. The i-node numbers and their corresponding i-nodes are held in i-node tables.
OS-100
OS-101

You might also like