OS - Operating System Akash
OS - Operating System Akash
~
./}
Time : 1.30 Hrs.
System
. ~
th Semester, Operating
Sixth oe"
art of CPU scheduling information).
vee of proce SS ~
of processes.
ose e Ss (a p
é
yorr
emory
o locate m 2016-3
rea.
‘por Save a
nning OF.
essor it js ru
e The proc he What are the possible solutitions to bdlve this
tis star eer
Q.id) Wha
proble wm?Tn computer science, starvation ;
isi a problem encountered in concurrent
Ans:
here a process 18 perpetually denied necessary resources to process its work
algorithm. }
computin
~, W
-evatjogn may be caused by errors ina scheduling or mutual exclusion
we > be caused by resource leaks, and can be intentionally caused via a denial ut
-of-
k such as a fork bomb. 3 |
~aanStarattac
vation is similar to deadlock in that it causes a process
to freeze. Two or creating modular operating systems. Under the to
in an
processes become deadlocked when each of them is doing nothing while wait functionality and
and |
feat ures. are determined and th € separated into com
rce occu
resouation pied by anot her prog ram in the same
that is set.
cont On
inuo the
uslyothe r
give nhand.
to a
otk ro
Proc ea
ess e—
isin Information hiding is also important, because
it leaves programmers free tore
starv when it is waiting for a resource the low-level routines as they see fit, provided that the ext
Starvation-freedom is a stronger guarantee. than the absence of er processes, ernal interface of the routine
stays unchanged and that the routine itself performs the advertised task.
exclusion algorithm that must choose to let one of two processes into A system can be made modular in mafiy,ways. One met
picks one arbitrarily is deadlock-free, but not starvation-free. hod is the layered
approach, in which the operating system is broken up into a number
of layers (levels)
Possible solution: A possible solution to starvationj The bottom layer (layer 0) id the hardware; the highest (layer N) isthe user
interface.
with priority queue that also uses the aging technique. Aging isa te An operating-system layer is an implementation of an abstract object made up of
chnique ofgradually
increasing the priority of processes that wait in the sy stem for a long data and the operations that can manipulate those data. A typical operating — system
© time.
Q.1.(e) Explain race condition wit
) h Suitable e xample? layer-say, layer M-consists of data structures and a set of routines that can be invoked
—
Ans: Race conditions are most commonly by higher-level layers. Layer M, in turn, can invoke operations on lower-level layers.
In associated with computer Beton ¥
computer memory or storage, a race condition may occu The main advantage of the layered approach is simplicity of construction and
‘a large amount of data are receiv r if commands to read and write |
Paitin
ed at almost the Same instant, and the machine
debugging. The layers are selected so that each uses functions (operations) and services
wtingy
:
attempts to overwrite some or all of the old data while that ol of only lower-level layers. This approach simplifies debugging and system verification.
d data is still being read.
ait,
inn
The result may be one or more of the fo The first layer can be debugged without any concern for the rest of the system, because,
llowing:a computer crash, an “illegal oper
ES i
notification an ation,” by definition, it uses only the basic hardware (which is assumed correct) to implement
dim ta : i ee Si
d shutdown of the program, errors read
Ot
ing the old data or errors writing
the new data. A race condition can also occur if instructions
its functions. Once the first layer is debugged, its correct functioning can be assumed
are processed in the incorrect while the second layer is debugged, and so on. If an error is found during debugging of a
order. |
em
particular layer, the error must be on that layer, because the layers below it are already
ei
Example: Suppose for a moment that two processes need to perform a bit flip ata debugged. Thus, the design and implementation of the system is simplified.
sas
specific memory location. Under normal circumstances the operation should work like ' Each layer is implemented with only those operations provided by lower-level layers.
Soil Stn
this: ae | A layer does not need to know how these operations are implemented; it needs to know
,
Process 1 | Process 2 Memory Value | | ’ only what these operations do. Hence, each layer hides the existence of certain data
structures, operations, and hardware from higher-level layers. The major difficulty
Read value | 0 with the layered approach involves appropriately defining the various layers. Because
Flip value. 1 } layer can use only lower-level layers, careful planning is necessary. For
example, the
hes: Read value , 1 memory algorithms)
- device driver for the backing store (disk space used by virtual-
Flip value — 0 er level tha n the memory -manag ement rout ines, because memory
must be at a low
—
not occur. Consider what might happen if a computer pro
program t
tryingto weet
wasvery Work and programs must be saved on a backing storage device so that they can be
)file
he
from i
a floppy disk and, at the same time, another program was
dd
kept when a computer is turned off. The operating system is responsible for organising
edemenanty ai
Therefore the operating system manages all of these tasks. If, for exam
ple, a program data on backing storage devices. Work and programs are saved as files which must be
- wants to save or print a file it must send a request to the o perating system
ibe ay asking it to organised so that they can be found and loaded when required. Each file is identified by
SiR
cals Odean
do so. The operating system will then carry out the task. Cy Case eae a filename.
Because an application such as a spreadsheet works by communicatin
g with the Most operating systems divide a backing storage device up into directories (also
Saal
operating system the application will probably only work with one particular known as folders). Files can be stored within each directory.
a
operating
ni atin
system. If you buy Microsoft Works for Windows 2000 it will only operate on computer active
s Q.2.(6) On a simple paged system, associative registers hold the most
di
bie the Windows 2000 operating system. If you want to use Microsoft Works with the references
page entries & full page table is stored in the main memory. If the
fren
-DOS operating system you will have to buy a different version of the application. sfied by the asso ciat ive regi ster s take 100n s & reference thr ough the main
sati
;
to be achieved on
memory page table take 180ns.What must be the hit ratio
Ss
| : /
Computer Softwar effective access time of 125ns?
Messages t 7 | Ans: Effective Access Time= [x*(m,+m,)] + [(1—x)*(c + m,+ m,)|
ters, M, represents
| Operating System Where m, represents references satisfied by associative regis
esents the hit
Electric Signals , reference through main memo ry, c repr esen ts acces s the page table , x repr
180x = 460-125
180x = 335
x = 1,86%(Hit Ratio)
~~
=< 2
Q.2. ) Sixth
©xXambple me
hat j Belady: A i ~ Perating Sy
ps
S | stdm
Ans: elady’ omaly? Explain with the } l eat
i 0 frames Ile amaly is algo ~ P Of suitabig LP. University(B.Tech)-A
time© s? weesr éspage fs aul
atsa Toc B Publisher
Soese
m ' vi
lgI memochryom,alythe Usu all y, on increas; reasing the
ine as
Anom aly. Ty: ccur, Q.3.(6) Consider the fo
°°" When Pro ces s ex
- Chis ig true for at ‘ etmes, the reverse h
“Xecution is faster
time in milliseconds?
Example i frames “re allocated
ain page to © Dappens, i.e., the €xecut
finns dans © io Process
1: In th pro cess. This is Belady’,
€e faults are marked
P
S Case Assy With an “> oe: A 0
me fr am e 5;
oh B
i Requests
a7
1
. =
ewest P age A Og
C 2
Ol) “Or ye aS
| D 3
as rhe | E
Oldest Page ; 4
oar caleng Siac, Bi Draw the Gantt chart & find:
2: In thhis
eo ee 1
j case Assume (i) Average waiting time for these proces
frame Size is OS
4
B dau. Ga Baa Time Fir
ses with the shortest Remaining
| | st, Round Robin (Time quantum=3ms) & FC
FS scheduling algorithms.
“a (ii) Average turnaround time for these processes with the
Newest fiOe ene id
shortest Remaining
Page Time First, Round Robin (Time quantum=3ms)
& FCFS scheduling algorithms.
3f ALTE i 6 ORO ean 4f se : Ans: Gantt Chart for FCFS
i “
BPs po a dle al Oi
:
ig 2 ate ;:
S82 OO AI|BICIDIE
Oldest Page ae 3 9 0 10 15 23 27 38
83558 ne BD 1
In the first exampl Ore | - For FCFS:
e (with fewer pages),
there are 9 Page fau
In the second example lts
(with more pages) ther
e are 10 page faults
: ; Process | --AT BT cr | varacraD | wr-carey |
& criteria? A es: 10 10 10 0
Ans: There
scheduling algorithm -
are man y different criterja’s
to check when consi B 1 5 15 14 9
dering the “best” C 2 g 23 21 13
I. CPU utilization: |Ts D
make out| the best use
of CPU and not to, wast
3 4 27 24 20
cycle, CPU would be wo
real system, CPU usage sh
rking most of the
ti me (I de al ly 10 0%
e any CPU
of the time). Gcnsidering
E 4 uu 38 34 23
ould range from 40% (lightly a
loaded) to 90 (i) Average Waiting Time=(0+9+13+20+23)/5=65/5=13ms
|
(ii) Average Turnaround Time=(10+14+21+24+34)/5=103/5=20.6ms
~
.
Gantt Chart for SRTF
7
——
3. Turnaround time: It is the amount of time AIBIDICIA\E
em
i.e. The interval from time of submission of the pr
“pk
O° 2 6 10 18 27.38
~~
-
process(Wall clock time). Sas
ie
|
For SRTF:
Ate
“a
a
AT BT CT |. TAT=(CT-AT) =(TAT-BT) |
Process
Ainitiacn
Fog 0 10 27 27 . }
al
23+417+23)/5=98/5=19.6ms a
<
“thread-safe object/c lass /mod ule’ we
*
Fro em?
:
lain the Dining Phi los oph ers
1. Mutual exclusion: If process is executing in its critical section, no other process
ies
(ec). ion problem
.
are a clas sic sync hron izat
ers problems
le
ak e Phi los oph
6 eee:
is executing in its critical section Sc Proc esse e): xy
Sequ enti al
there exists some (E. W. Dijkstra. Co-operating
:
s is ex ec ut in g in its cri tic al sec tio n and room ae .
eit
2. Progress: If no pr oc es e is a dini ng
onl y tho se pro ces ses tha t are Dining Philosophers: Ther = : gee ,
sin Str ge
al sec tio ns, the n k .
processes that wish to enter their critic with five chairs. ie } e
th e de ci si on of wh ic h will circ ular tabl e
section ca n pa rt ic ip at e in chopstick. 1n
not executing in their remainder e is a sing le Bs
§7
tween each plat ann
indefinitely san d
’
is de ci si on cann ot be po st pone d Near the room are five
and th hett i.
enter its critical section next, oe is abowl of spag y :
thinking, but who —
ci de qu ic kly who enters most of thei r time
sect io n, ca n de who spend m aa
If no process is in critical ar e pu t on the @- so they can thin k name
th e cr it ic al se ction so in pr ac tice , others hungry and need to eat sit at the table, P
en te r must
Only one process can In order to eat, a philosop
her
of a pl at e, t h e n serve and
left and ri gh t
a e ee ~< | i the tw o c h op st ic ks to th e
ro
ex is t a b o u n d on th e scar
e d w a i t i n g : T h e r e must f achetti on the plate. th e fo ll ow in g pseudocode
3. Boun d al s e c t i o n s af te r a process ilosopher is represented by
w e d to e n ter thei r cr it ic = oa a k ph
senoabae s ar e a l l o q u e s t is
i g r a nted
ti c a l s e c t i o n a nd before t h a t r e
e n t e r it s critical — process P{i]
to ent e r it s cr i
a k e s a reque s t to
r o m when a p r o c e s s m while true do
is the t i m e f
The wait "HINK;
est is granted another turn 4 )
t get KL i+ 1 mo d 5)
section until that requ i s a s
itical sma e c t i o n , it d oe s n o
| rACK UP (C HO PS TI CK L) , CH OP ST IC
rocess e n t e r s it
In practice, once a p anag CHOP S T I C K L i + 1 m o d 5])
p r o ce s s ge ts a t ur n ( m N (C HO PS TI CK L
until a waiting ‘ttiical s e c t i: o n p r o b l em ae TDOW
i r e m e n t s f o r c r i its q b
T h e t h r e e r e q u ha s al read y ch os en }
i t i c a ] se ct io n an d Pk(k!=i)
t h a t P i is in its cr
Suppose
t h e r e a r e t w o cases:
- number'[k],
a =e Oa
et
|
request for that data can be served faster. poneey called Oneia » SO that fut, - . Aphysical file contains one record
; ;
for
l eaiat Sea iat record d formats.
€
ontain up to 32, |
|
* A ;
spécial hig h-speedndstor age mec han ism. It can ie athe. ae | 3 ae
Wai
main memory or an indepe ent high-speed storage device. €rved Sectigng | 4. If there is aloo; = 3. Can’t exist without PE |
e The data that is stored withi : a a logical file for a PF, the 4. If there is a logical filef ——_|
earli duns an e t ie in a cache might be values that have b il PF can’t be deleted until and unless LF can be deleted wiwithout edel eng
reti
ve Computes we delete the LF. the PF
Dj ay ate ae aa of original values that are stored elsewhere. E.g: Me
1S i ac ae , Web Caching(used in browser), Database Caching ete. ae Caching 5. CRTPF command is used to create 5. CRTLF command is usedio |
ey e i os purpose is to reduce accesses to the underlying slower storage | such creat such object. | object.
° | : : ——
= Q oie @ . i
ae ;
with 1000 cylinders, numbered 0 to 999, compute the - | Q.3.(a) Consider the following snapshot of a system.
of tracks the disk arms must move to satisfy the entire request i: Umber ,
queue. Assume the last request serviced was at track 345 and heaq f be disk ised oan Allocation Pee 5 on
towards track 0. The queue in FIFO order contains request for the tie AB CD A BC D ABCD
OWing : |
) 376.
° 23,87 4,692,345,475,105,
aca. :1 Perform the computation for th followin Pl 0012 OO 12 i FS 2E
scheduling algorithms- 3 | () P2 1000 L750
,\(@) FIFO | (2) SSTF (3) SCAN P3 1354 2356
(6) C-LOOK | 4 P4 0 6 3:2 0652
| (4) C-SCAN (5) LOOK
a
ve unique name (4) Acyclic Graph Directory
directori=es
ries : catal a } at,
Acyclic Gtaph is the graph with no| cycles. It allows directo
i
(c) Files are limited in length. and files: With'a shared file, only one actual file exists, so any
(d) Even a single user may find it difficult to reme mber person are immediately visible to the another.
the names of all file
number of file inc reases : s as} ' Inplememtation of Shared files and directories
| |
(i) To create a link
of yso many file | is daunting task.
trackctor
(e) Keeping Dire Alink is effectively a pointer to another
ile or sub os nga
(2) Two Level in both sharing
Duplicate all the information about them
(i) Each user has Its own User File Directory (UFD),.
oe
yf nena
—
ii) Dele ting a link
file, ie i
i
(ii) When the user job start or user log in, the system Master File Directory Mr eee of the link will not effec t the orig inal
is searched. MFD is indexed by user name or Account Number. | | “a to it are deleted.
=—
the file unti l all refe renc es
- - To preserve
me
(11) When user refers to a particular file, only his own UFD issearched. - 3.
N
Thus different users may have files with same name. To have a particular
uniquely, in a two level directory, we must give both the user name and file name,
A two level directory can be a tree or an inverted tree of height 2 ;
The root of a tree is Master File Directory (MFD). |
of i :a
Its direct descendents are User File Directory (UFD). The descendents
file themselves. | |
The files are the leaves of the tree.
es git sh
Limitations of Two Level Directori
ly iso lat es one use r tro :
The str uct ure effective
ry
(3) Tree Structured Directo
os
ir
e s a m e in te rn al pe ar
directories has th
y en tr y r d e a e
in each direct or
(i) One bit S aw aa l
ar e us ed to create and de
(ii) Sp ec ia l ca ll s d contain mos}?
curr ent di re ct or y. Cu rr en
nae rule process has a t to the process. ched.
(iv Aa
* hos a ref erence is made to a file, the current directory
~
ena
—a
LP. University-(B
Tech)-AB Publishe
r
Relocati-
ve questions includi
ng Q. No. ] which is on
| Q.1.(a) Compare multi compulso Mo, ,
Systems. -programmed Logical | 14000 | physical
batch CPU address 3 address ssl
a te , J
Systems
346
}
Ans Multi-programme
d S
and tim 14346 meer
:
:
3
ectories. _
copy, rename, ‘ . 8 A
(i) Mutual exclusion
Print, du
(c) Communications: These programs (ii) Hold and wait
provide the mechani iS]
connections among processes, users, sm for creating (iii) No preemption
and co mputer systems.
deVisgeualn,Bas
4d) Programming-languag (iv) Circular wait |
e support: Compilers, assemble
interpreters for common pr
ogramming languages (such
rs Q.1.(g) Compare FA32 and NTFS file systems.
as C, C++, Ja (2)
and PERL) are often provided to
the user with the operating system va, Ans: FAT32 is one of the most commonly used file systems around. Most Operating
Q.1.(c) Explain memory manageme . systems, including Windows 98+, OS X, Linux, support the FAT32 file system.
nt strategies. NTFS has lower support and has only read support in OS X.
Ans: Two basic memory management st : a
rategies are FAT32 does not support file compression, encryption and other functions supporte
¢ Paging . by NTFS.FAT32 has a upper limit of 2TB on Hard drives and a limit of 4GB on omer
files. NTFS on the other hand, has a limit of 16EB for both hard drives and single files.
° Segmentation
_ (1 EB or Exabyte = 1024 petabytes and 1 petabytes = 1024 terabyte).
Paging: Paging is a memory-management scheme that permits the physi Q.2.(a) Explain the features of parallel systems und distributed — 2
address space of a process to be non-contiguous. . 2
Segmentation: Segmentation is a memory-management scheme that supp Ans: Multiprocessor systems(also known as parallel systems or tightly ae
this user view of memory. A logical address space is a collection of segments. Bit systems) are growing in importance. Such systems have two or more processors im close
communication. Sharing the computer bus and sometimes the clock, memory, and
S egment has a name and a length. The addresses specify both the segment
t oe
eae
- a A
F =ae
peripheral devices.
the offset within the segment.
+ i
|
Se
Q.1.(d) Explain the process between mapping of logical address 7 F a Increased throughput: By increasing the number of procs * awed &
physical address space. { :
get more work done in less time. When multiple processors coopera
Ans: The run-time mapping from virtual to physical addresses is done by a a
device called the memory-management unit (MMU).
| d to every addr
The value in the relocation register is adde by.aus | , quivalent
ess son bya at a. waaanctn of scale: Multiprocessor systems can cost gente tt
Process at the time it is sent to memory (see Figure). For example, fe mer. pee pe w a wu ceasets
multiple single -proce ssor system s, becaus e
> he 18)
be yy ae
ES sell Re
a Ans : FIFO Page Replacement:- The simplest page-repiacemen
Me
thedpt mien waits cate available memory to the processes that are in pag : P to hold all es in memory.We
4 replaced, the oldest page is chosen. Create a FIFO queue 0 pag .
ing to be brought into memory. In this contiguous memo
each process is contained in a single contiguous section of memo - allocationyy replace the page at the head of the queue. When a page is brought into memory, we
‘ Contiguous memory allocation is a classical memory siodaenie del thatthat assigns a— insert it ak tie $ail:of the qneuns Tie SiO ene trea
is erg meee
; model
nie memory blocks (that is, memory blocks having consecutiv — arab phones Meee SS eee cee
sees a der frame size = 3
FIFO ii: g i
. xample,
enna
nge dynamicall y.
es ee
This flexibility is desirable
; .
1
in many aoperating-
an effective way to allow the
the operating system contains code and buffer space for device situations
drivers. For eg . payedenes seat
:
66. PO. 6.9 to OSG ee SS
However, since all its pages are in active use, it must replace a page that will i z
es
ee
admitted interrupt
needed again right away. Consequently, it quickly faults again, and again, replacing
pages that it must bring back in immediately. This high paging activity is calla
oe
washing. A process is thrashing if it is spending more time paging than executing a
Juha,
Tie Ml Smee ty
di
o
i Oo
a. B
a 7
e
cE
So
>
ex
o
oO
hy
So
BS
ct
ne)
ry
es
©
S
@
-Q
mM
B
°
=
~
Den
he
o
»=cilization. If CPU utilization is too low,
Pin!
ahs Sa ~
utilization
be B68
f
‘We increase the degree of multi-
a
DS
= WF nse as
programming by introducing a new process
adh -
trashing
to the system. A global page-replacement
algorithm is used; it replaces pages Q.4.(a) Explain various type of inter-process communication. Give an
CPU
ee
illustrate for each. - (6)
belong. Now suppose that a process enters Ans: Cooperating processes require an inter-process communication (IPC)
a new phase in its execution and needs - mechanism that will allow them to exchange data and information. There are two
more frames. It starts faulting and taking fundamental models of inter-process communication: (1) shared memory and (2
frames away from other processes. These 3
degree of multiprogramming a message passing. :
processes need those pages, however, and so they also fault, taking In the shared-memory model, a region of memory that is shared by cooperating
frames from other!
processes. These faulting processes must use the paging device to swa p pages in an ia processes is established. Processes can then exchange information by reading and writing
data to the shared region. In the message passing model, communication takes place by
means of messages exchanged between the cooperating processes. .
Both of the models just discussed are common in operating systems, and many
systems implement both. Message passing is useful for exchanging smaller amounts of
data, because no conflicts need be avoided. Message passing is also easier to implement
than is shared memory for inter computer communication. Shared memory allows
maximum speed and convenience of communication, as it can be done at memory speeds
when within a computer. Shared memory is faster than message passing, as message-
passing systems are typically implemented using systein calls and thus require the
more time consuming task of kernel intervention.
y IER “ss
In contrast, in
Shared-
shared-memory
regions
as routine memo
ry
LE University—(B.Tech)}-AB
Publisher
T, and T, are executing the same operat 2016.
Process A ion wait(
& process A
.
Sidhiacs is not atomic and T, updates the valueS) simultaneously since the wa
updates(overwrite the value written by T.) the actual of S and at the same timal
L PhMetess B ~ Shared memory d |
but the simultaneo exe
usly cution causes decrement in only 4 Phin jeans value of § ,
| “process B. = race condition and this causes an inco : 2
ee tas pe ea acl ee ; as ia
has more resources available than it truly does. a a a thinking it
Q.5.(a) Consider the system consistin
g of m resources of the same ty
shared by n processes. Resources c an be re pe he;
quested and release by Proces
.
only one at a time. Show that the s ystem se
is deadlock
:
se processs with cp
’ -
a may need. This number may not exceed the total number of resources in the system.
heduling? 1 *
si
e When a user requests a set of resources, the system must determine whether the
_ Ans: ({) For FCFS
an
- allocation of these resources will leave the system in a safe state. Ifit will, the resources
~ are allocated; otherwise, the process must wait until some other process releases enough
resources. Several data structures must be maintained to implement the
0-8. banker’salgorithm. These data structures encode the state of the resource-allocation
419-43 3 a 4
Turn around time for P= 8 system.
Turn around time for P,= (12-0.4)=11. a 5 Let n be the number of processes in the system and m be the number of resource
6 ; pty types. We need the following data structures:
Turn around time for P,=(13-1)=12 2 a :
, e Available. A vector of length m indicates the number of available resources of each
Avg=(8+11.6+12)/3=1 0.533
unit. type. If Available [j] equals k, there are k instances of resource type Ri available.
(tt) For SJF
¢ Max. Ann x m matrix defines the maximum demand of each process. If Max\ilj]
equals k, then process Pi may request at most & instances of resource type. _
L2 1 BTR TR Le ¢ Allocation. An n xin matrix defines the number of resources of each type currently
0 04 10 2.0 5.4 183
allocated to each process. If Allocation{i][j] equals k, then process Pi is currently allocated
Turn around time for P,=(13 k instances of resource type . :
— 0.0)=13
Turn around time for Po=(
5.4 —0.4)=5 ¢ Need. Ann x m matrix indicates the remaining resource need of each process. If.
Turn around time for P,=( Need{il[j] equals k, then process Pi- may need k more instances of resource type R- to
2.0 -1.0)=1
on (13+5+1)/3=6.33 unit complete its task. Note that Need [i]lj] equals Max [i]j] Allocation{il)).
automaA.ti(cca
) ll§y 1, case if0 tithee waiteons Safety Algorithm
and signal oper| ation are no We can now present the algorithm for finding out whether or not a
system is ina
pr oc es s t executeted — ows: a ere
se Violated. s ynchronization), then mutua safe stat e. This alg ori thm can be des cri bed , as foll
l exclusive may be
len gth in and n, resp ecti vely. Initialize Work =
ens © : wai
Lett(Sus) wait(S) ( while (S <a | — 1. Let Wor k and Fini sh be vect ors of
}
0) ;/busy waitS--} Available and Finish [i] - false for i-0,1,...,n-
operation is not atomi "a a
d ¢1.€ all operation inside wait(S) are not executed 2. Find an/ such that both
(a) Finish [i] ==false
“~ Go to Step 2 LP. University—(B.Tech}-AB Pu
blisher
4. If Fin; Al; * One reason is to cope with a spee
2016-29
esource-R. t] d mismatch between the producer
“dest— Al true for all, s then the
Wa. of a data stream. and consumer
gorithm system is in a 8afe
state e Asecond use of buffering is to ada
éTanted L W d e s crib pt between devices that have different data-
et Reques e the transfer sizes
t; be ther * Athird use of buffering is to support copy semant
ics for application I/O.
If Regues; t [7] C=-c hiA cac
ng he is a region of fast memory that holds copies
request for re of data. Access to the
cached copy is more efficient than access to the original. For ins
tance, the instructions
of the currently running process are stored on disk, cached in physic
al memory, and
copied again in-the CPU’s secondary and primary caches. The difference between 3
buffer and a cache is that a buffer may hold the only existing copy of a data item,
whereas a cache, by definition, just holds a copy on faster storage of an item that
2. If Requesti< Availabl resides elsewhere.
e go to step 3
Otherwise, Ps must Q.6.(c) Explain the recovery technique used in deadlock. (4)
wait, since the resource
3. H: ave the system s are not avai Ans. Recovery from Deadlock
pr et en d to lable.
by modifying the state as foll ha ve al lo ca ted the requeste When a detection algorithm determines that a deadlock exists, several Serer
ows: d res ources to Process : ;
are available. One possibility is to inform the operator that a deadlock has a i’ s
Available = Available-Requesti; a to let the operator deal with the deadlock manually. Another ee at ae fat
Allocation = Allocationi + Requesti; system recover from the deadlock automatically. There are two options = SiS - ;
Needi = Needi—-Requesti; deadlock. One is simply to abort one or more processes to break the circular :
| | | = other is to pre-empt some resources from one or more of the deadlocked processes.
(a) Process Termination
To eliminate deadlocks by aborting a process, we use one of two ee
methods, the system reclaims all resources allocated to the nae Se a
e Abort all deadlocked processes. This method clearly will bre kak Ga alan
are shared by three Processes, cycle, but at great expense; the deadlocked processes sik ep tata tank ockalls
that the system is deadlock-free. time, and the results of oe partial computations must be
. ater. : let
ae are R1,R2,R3,R4 processes .let us consida, ie ee REL pA ISS at a time until the deadlock cycle ae heey
s R1 ,P2 holds R2 andpyder
and pr
20lds R3.R4 is free .Ever i ethod incurs considerable overhead, since, after each process 1s abo ee
‘ detected algorithm must be invoked to determine whether any pr
deadlocked. 600
; tion é | . £ ome
the return trip ts on Myj sea t When a user job starts or a user logs
ee i “file ‘ of sam
lists only the file
Q.6.(6) Explain the role of c atching and buffering used in devic
manageme { UF tu
an when the users are
ive attributes. ints to the UFD for =
“_ ee ee a another. Isolation 1s gore sn eaaanateiett
ane
— oh at but is a disadvantage when the
ee tely indep
sumuill done for three reasons. one another’s
>
files ;
ea to access
VU—2UL0 OLALTL vemester, Operating System
ique: Tb provide efficient ant
disk, the operating system irncbas ce . file ayat aha to allow wt C886 ty
ees Sree co Sue easily.
oe oaiban Wi eat 0 ac is defi ning Ahow
file system poses two quite differ vata ton
the file system should look to thers esi,
sera day so aaa a & file and its attributes, the operations allowed on a file The
ate seraikinhes = ean chia files. The second problem is creating algorith
4 the
eee P the logical file system onto the physical Secondary.gt ang.
Tap,
ane file system itself is generally com posed of
. .
| "athe
When a user requests access to a particular file, the operating system checks
access list associated with that file. If that user is listed for the requested accep 8 the
access is allowed. Otherwise, a protection violation occurs, and the user job ig ea
access to the file. | “Tiley
proces s: Data integri ty refers to the accurac y and consists ‘
(d) Data integr ity
of datastored in a database, data warehouse, data mart or other construct. The tend
_ Data Integrity - can be used to describe a state, a process or a function — andj, aft
used as a proxy for data quality , se ty
(e) Explain multilevel feedback queue scheduling. Give applicatio,.
Normally, when the multilevel queue scheduling algorithm is used, proceggeg ,"
permanently assigned to a queue when they enter the system. If there are sepa...
queues for foreground and background processes, for example, processes do no
from one queue to the other, since processes do not change their foreground or bac Dung.
nature. This setup has the advantage of low scheduling overhead, but it is inflexible —
The multilevel feedback-queue scheduling algorithm, in contrast, allows,
process to move between queues. The idea is to separate processes according to the Ana. The address generated by CPU is logical address. Log
characteristics of their CPU | —— ical address is generated
when instruction or data are executed. During its processing
bursts. If a process uses too ee ee by CPU it generate some
As address for allocating some space in memory. This address is known as logi
much CPU time, it will be = 8
quantum cal address.
moved to a lower-priority NE CREATE OOS Ea aie g The address generated by memory unit: to load the instruction and data in
to
queue. This scheme leaves I/ 2 memory register is known as physical address.
O-bound and interactive : emma wisi scr ait _ |
processes in the higher- eee “quantum = 16. a > Physical address is used in main memory where as logical address is used in
priority queues. In addition, Lenni virtual memory.
a process chat waits too long Physical address is divided into small parts called frames and logical address is
in a lower-priority queue
divided into small parts called pages. |
may be moved to a higher-
= Priority queue. This form of Logical address (virtual address) refers to a memory location independent of the
aging prevents starvation. current assignment of data to memory
_ For example, consider a multilevel feedback-queue scheduler with three queues, : Physical address (absolute address) the absolute location of unit of data in
| pein from 0 to 2. The scheduler first executes all processes in queue 0. Only |
when memory’
a ot : empty will it execute processes in queue 1. Similarly, processes in queues
> © executed if queues 0 and 1 are empty. A process that arrives for A logical address is generated by the CPU and is translated into a physical
queue 1 will
queue 2. A process in queue 1 will in turn be pre-empted
by# address by the memory. management unit (MMU). Thus, Physical Addresses are
8 arriving for queue 0. generated by the MMU.
/ Vv
EEE NI PCL AUALIE, WY SUCIT)
Q.4. 4. GiGiven mem
ory partition
(in order). H of 100 KB, 500 K
* ow would e B, 200 Kp, 300
| e fi‘nrsott fifit,
ach of th
v “e Process of 212 KB bes t fit and Worst An q
f0rithm makes the mo
, 417
KB, 112 KB and 426 KR
*j
st efficient use of mem (in 5
a
ory? | “tery
Ans. (i) First-Fit |
212- KB_500
417 KB_600 KR
KR 100 KB, 288 KB, 200 KB, 300 KBV, 699,
100 KB, 288 KB, 200 KB, 300 KB, 1g3 pp
<a
112 KB_288 KB
100 KB, 176 KB, 200 KB, 300 KB, 183
426 KB_Wait (no partition KR
is large enough) 100 KB, 176
(ii) Best-fit KB, 200 KB, 300
: oS Se
a
212 KB_300 KR 100 KB, 500 KB, 200 KB, 88 KB, 600 Kp ; (FCFS)
417 KB_500 KB 100 KB, 83 KB, 200 KB, 88 KB, 600 Kp algorithm, in whicish ph
acenomenon latded wi with the e Fj
associate
hole Operating System slow First Come First
112 KB_200 KB processes. s down due to fe W i
100 KB, 83 KB, 88 KB, 88. KB, 600 kp FCFS algorithm is non-
Slow
426 KB_600-KB 100 KB, 83 KB, 88 KB, 88 KB, allocated toa process, other
preemp tive
in nature, that is, once CPU
174 KB time has beaca
= processes can get CPU time only afte' r the Current proces
(tzi) Worst-fit has finished. This property
of FCFS scheduling leads to th s
, Cea Effect. e situation called Convoy
212 KB_600 KB 100 KB, 500 KB, 200 KB, 300 KB, 38g Kp Suppose there is one CPU intensiv
417 KB 500 kB 100 KB, 83 KB, 200 KB, 300 KB, 388 Kp and several other processes
e (large burst
with relatively less burst
time) process in the ready queue
112 KB_388 KB 100 KB, 83 KB, 200 KB, 300 KB, 276 KR a. bound (Need I/O operations freq
uently).
times but are Input/Output (UO)
ofojolsl= ; aa
pferele am )woln
jo}
|
aa7a
oy *
; | 9 :
<T (|\ ” ele
-J i”
:
12
p 2 ae
a (o oOo al<-
<Pele
| a ro ] Te)
fo[s
i ora
:
SI wO\N| NS WL
ofofei7le
—
ae :
Ou.
f ®
offi)” :
E
AB Publiissnheer
icles"
Pp
:
Eafe 1 ™N o.{a ”
oD, (Taeleore!
|*4
2 3 55oc
| Se ined
nN
oy*
® :© © |
eo
afarn[ nse |
t“ c A x
.
a\st ees
h.
C B af-[alo1_)
@
orr e
wye
versity-(B.Tec
sii ao
ie seer alr|O)°? o
£3° :
o saitig flcis}° :
=[alo|?
£See | ‘J
63 elHl\N 1 a afol
e s|e “|
eae, E;
:a[-[s
d
io
v =
:
1 1
[.P. Uni
off = a[s|<|>
Lae
zi =
=
al AN}
ale]|e [>
| :
|
a7
x a
:= wi
|
z &
|
ZZ
a
ge .
Initially
£ w
é~
3
3
ss 7
i
al
. = :
4
——_ enteey?
mama
-.
(it)
=
_ [H[N[e[z]o]o
[R]
=[N]o[=]e]o ©
KENPO; s[oO;o: ; fa
oO
~“I1NIO[n [MO]
elalols [wl ol] o
e
Oe NL SteLee Sadc aie aoe
| w D>
TINIMiztiwlolrn alwlw
; =
£ iw
oe a
(wz)
© =w
Pry
6-2017
_
; =
: a
N
=
I.P. University—(B.Tech.|—-AB Publisher 2017-9
.
re Five 08 10
2] Six 07 : 10
| 3 Seven 07 O7
| = (iii) Optimal
2 3 4 ; 6 | initial 4 ; 4 2 { 5 6 2 1 2
At | BT | CT | TAT wt
Process |
3 10 | 16} 13 3
A
Exit 5s | 4
> ¢ borlLe }
Cc 4 | o2| 19) 15 | ‘13
D 3 | a1} 17 | 14 | 13
E o |o}5 | 5-10
A 3 10} 19} 16 6
B ‘ 1 2 1 0
n through the process (2)
track of which ins truc
tion to execute next,
code with its Wn
C 4 4.a.,6 2 | 0
king variables, a nd a stack wh 5 y s t e m reo. terg D $ bt 4 b1 0
i ch contains the
oe tion Ee tfjois\ioao\}o}l4
PR: (TQ = 3ms)
Process | AT | BT | CT | TAT| wT
A 3 10} 19} 16 | 6
el queueing
a
di ff er en t le ve ls of a e ee
Time First, Round Robin (Time quantum = ser vic ing , for ne
3 ms) & FCFS scheduling algorithm. _
s. Pr oc es se s wh ic h ne ed more frequent = ee ae
(ti) Average turnaround ti me for these processes An ti me qu an tu m.
with the SRTF, Round 3 s, ca n be in a qu eu e with a small
Robin & FCFS Algorithms. such as edi tor
eu e wi th a lar ger ee e = oe ee
a qu
for frequent servicing can be in sing, making more efficien
es to co mp le te the proces
TAT = CT
- AT swit ch
WT = TA-TBT
E|\|B|. A D.|C
Si -6 16 17 19
Publisher 2017-13
LP University-(B.Tech,.|-AB
; any f
TLBs can , r performance
suffe issues Ititasking and code errors. This
+!
Question from . ft © questi 28 inely; from mu by an ongoing
formance degradation is called a cache thrash. Cache thrash is caused by idk ta
each unit uding Q. No. 1 Wiii
wh ch igs compu]
Q. ay Answer th follow;
t}) och . ity that fails to progress due
computer activ to excessive use of resources or co
Sory Se Ct | the caching system.
Q.1. (a) What d “ng short answer questions: " Q.1. (e) What is the utility of cache memory in the system 9-
}
(2.5)
An 0 you mean b . RAM)
= Context Switchin Cach also called CPU memory, is random access memory (
one Switching ? t caaimulae made aden ia access more quickly than it can access regular
is the: swj
ee tching oftch
the (a]GE some
; vefi niti
time s on:
referred to as a Process Switch o (25, | an. rh eactaicay- di iledllly integrates directly with the CPU chip or placed on a
separate chipthat has a separate bus interconnect
another. A Process (also So central processing unit) from one proeaie 2skswitg with the CPU. ae :
7 The basic purpose of cache memory is to store program instructions eet
instance of a program) metimes referred to as a task) is an execy tities or thread: frequently re-referenced by software during operation. Fast access to these ms
Q.1.(b) Explain th “oy im, increases the overall speed of the software program.
Ans. Pre-emption © : conc ept of pre ‘ emptio. n. ee (2.5)
Where it is needed ? je | : uli iteria for CPU scheduler : —
Without OE oe ae ea ‘teria to consider when trying to select the “best
ull fica ; relers to the temporary interrupti
or its coop eration, with the intention en a esPensioa n of atask scheduling algorithm for a particular criteriasituation and
(245) Ans : There are sever erent
Te oa steht
2 ae i
Goline auled a conte xt Switch and isa typically performed by:res the:umethat
pre: tasKk] later, Thishe ag oe tizati
* CPU util izat onion - - Ideally the CPUPiwouldcusedbe slico
bustdy100% of trentthe 40%0time, so
Fane (lightly
resume yo eetasksae Tun
thieninOper
g inatin system
theg syst em authorized t sas ie Schedule,, waste 0 CPU cycles. On a real system CPU usag
OE eee ereate and lat loaded) (90 (beasiy ee
N eeded: d per unit time. May range from
4 *
Throughput - Number of eae ae ;
Sea Ma en scheduler preemptible has the advantage of better system res 10 / seco nd nar
to 1/oun
hour the !specific
* Tur depe ndin g on
d time - Time requ ired for a particular process to comp lete, from
atabuty, but comes with the disadvantage of diitions (where th ii
Process accesses the same resource befor
Gnip
8¢
th ol race cond : a
i “XCcuting
seatert ti letion. ( Wall
SU bmission time to. completi clockproce
time. ) spend in the readdyy queue waititiing
re anot her preempted process finished using it) e Waiting time - How much h time sses q
eile Aue
(C 1s cuss various types of resources ? ume p
(25)AY their« turn to get on the CPU 2
rage number of processes sitti2 ng in5 the ready queve
Ans . perating system resources are the physical or virtual components
of limitaa o (Load average -The poe Reported in 1-minute, 5-minute, and 15-minute
availability within 4 computer system. Every
device connected to a computer cvetanil waiting their turn to get aes ) nor 2a
< resource. Every internal system component is a resource. Virtual system resouail See ses nae m3?
include files, network connections and memory areas. taken in an interactive program from the issuance of
‘ e Response time -The time se to that command.
CPU time, ; memoryLory (rand
\Tanotdom access memory as well as virtual memory), } mma nd to the commence :
seco ndar y * o of a resp on :
mean by deadlock? Is it possidte ‘ble to have a dead lock in
storage like hard disks, network throughput, battery power, exte
_ resources of a computer which an rnal devices are al]s | Q.1.(g) What do you
; 9 (2.5)
operating system manages. . ing only single process: ing the same
Q.1.(d) Describe the role of TLB | arya suk : a situation in which two computer ae ees “ting in
in address translation.
Ans. A translation lookaside bu (2.5) 3 ffectively preventing each other from accessitisopera ting systems ran only
ffer (TLB) is a memory cache tha
translations of virtual memory to phys t stores recent Se ee i ee to function. The earliest computer
ical addresses for faster retrieval. both program
When a virtual memory addre Ss is refere |
nced by a program, the search starts in
the CPU. First, instruction caches are checked.
If the required memory is not in these
very fast caches, the system has to look u p the memory’s
physical address. At this point,
TLB is checked for a quick reference to the location in physical memory.
When an address is’searched in the TLB and not found, the physical in a system. :
memory must ¢ Mutual Exclusion.
be searched with a memory page crawl operation. As virtual memory
addresses are ° Hold and Wait.
translated, values referenced are added to TLB. When a value can be retr
ieved from
TLB, speed is enhanced because the memory address is stored in the TLB on e No Preemption.
processor. )
Most processors include TLBs to increase the speed of virtual memory operations throu
gh — :
failing a necessary
_ 1] ‘rcular wait with only
a circ le with the first one.
the inherent latency-redu cing proximity as well as the high-running frequenc
ies of current — re +s no second process to for m
Icinnab er es a "The
m™ CPU’. ad lo ck in vo lving only one
n for Ci rc ui t wt de
TLBs also add the support required for multi-user computers to keep memo
nd it
co it j io ssible to have a ‘ ntaining free spaces on disk. (2.5)
ry — d fast
| Separate, by havinga user and a supervisor mode as well as using permissions on read — me 21. ~ Discuss various Gi GORS a rai atio n of fi le s p a c e a n
nd write bits to enable sharing. | Ans. TheThe main idea
= : behind allocation in See
loc on
©
) access of the files. There are three types
,
’
;
>
:
*
:
-e
:
re
.
14~2017
Sixth Seme
Ie contiguous r, Operating
allocation Systems
linked all
ocation
CPU P ists d ft . =
page Number frame number
if want ‘ |
:
us allowing access to the file.
mee
to acce 0
JA file’s inode number can be foun
d using the Is -i command. The Is -j | ——
Prints the i-node number in
the
comman; number
first column of the report. 3 L_>3 (2)0 = Qa 10
4 Y 2 wor
5 A ae
; rking of paging memory manageme
paging with segmentati nt scheme, Compar 6 3
on. 7
t
Ans. Paging is a Memory (6.5) frame numbe Physical Memory
contiguous allocation of ph
mana gement scheme that elim Page Map Table (PMT) in binary
ysical memory. This scheme inates the nee d for or Page table
space of'a process to be non — contig permits the physical address
uous.
¢ L<S‘cal Address or Vi rtual Addr 3 ed by CPU is divided into - VT ncieal
ess (represented in bits): An ad facrons ees cee of bits required to represent the pages in Logi
by the CPU dress generated ° Page num .
¢ Logical Address Space or Virtual Ad { A ddve Page number . Pi ae
dress Space( represented in words or :
a ae
_ The set of all logical addresses genera bytes); :
ne ~ aoe Number of bits required to represent pat
ted bya program .
)
of a page or p
* Physical Address (represented in bits): An addr or page once
s1Z Logical Address Space or word number
ess actually available on memory
unit Physical Address is divided
into
* Physical Address Space (represented in >
words or b ytes): The set of all physical -
~~
s
(ae.
Example: | i
*
™ G = 2%) _ offset.
|
—
\ 7a
e ~are
perichcs the -jyexcelience f~ \
¥ ue ll
So -
Sixt!
16-2017
ixth Sem este
Basis. for ster, Operati ng Systems
C : Paging
omparison Pu bl is he r 2017-17
Segm
ent LP. Univer si ty -( B. Te ch .| -A B
“ots : creases the degree
in e >
at io n an d
Basic
k easing CPU utiliz
. Page is Of fixed }]
| he du le r se es th e de cr
. used. The CPU ac
Fragmentation agi Ock siae A segment ig :
of multiprogramming
;
f sing may lead to ; Ze Variab] gr ee of mu lt ip rogrammung.
0 internal Segmentati ;
ted agains t th e de
p a t i
(2) CPU utilization is plot te
Ry )
Address ragmentation :
on
may le Ny ming increase s, CP U ut il iz at io n al so increases.
external fra (3) | As the degree of mult
iprogram
c:tio.tion, "ty4
|
The user spec} enta
SMg De he r, th ra sh in g sets 1n and ©
idesided by
is diviv dU inadtdr
peCP ess The user
Wig hedertrey of Se cies oe ig increased fu rt
by two ee. cay
address
Page number and of
fic P
itieg , utilization drops sharply. an d to st op th ra sh in g, we must
: segment numb th is po in t, to in cr ea se CPU utilizatio n i
and : i (5) So, at gramming.
ize offset (Segment = livmit), ea se th e de gr ee of mu lt ip ro |
th, decr of the minimum
The hard le decides the The segment g is caused by un de r al lo ca ti on
Tabi pgs "Ta th e pr ob le m: Th ra sh in
nt in uo us ly pa ge fa ul t. Th e system
by a process, forcing it to co
Eliminat e
“128 ig Specif: |) level
user,
by the ta s; numberof pages required aluating the level of CPU utilizationas compared to the
ee volves a page table Serm en can detect thrashing by ev l of mu lt ip ro gramming.
Pth agi Ng in
ntation involyooN re du ci ng th e le ve
:
at contains base addr thy of multiprogramming. It can be eliminated by 4,2,1,5,6,2,1, 2,
ee segment table that Ba llowing page re fe re nc e st ri ng 1, 2, 3,
of each page. and aa Q.3.(a) Consider the fo d oc cu r fo r fo ll ow in g replacement
le number 2, 1, 2, 3, 6. Ho w ma ny page faults woul (5)
Offsg, 3,7, 6, 3,
; segment length). es):
algorithm (Assume three fram
me |
(b) Given
Q.2.
- memory partitions of 100 K | F
(i) FIFO
Where will the ’ 500 K and 60
0K (in ge
processes 212K
e algorith
ithm, namely,best fit, fi
9 417K , 112K and 426K(ini order) in the memory? whe the (iii) Optimal th ea ch pa ge the time
algorithm makes the most efficient use of memory? | ich on,Ne FI FO : A F I F O re pl ac em e nt a l g o rithm asso sica te s wi
be re pl ac ed , the oldest
Ans. (i ) . When a page ™ us t
br ou gh t in to me mo ry
‘) when that page was
: 2k -> 500K (288 left)’ _ page in chosen.
ee -> We (183 left) Reference string e 6. 3. 22 0 258
3 ets e
x etn
->NoS
fa
426k 5 No Space 9\\2)\2 AL 4\ 2
| IG
|
SLe ni U3
s\tal Valls H
212k -> 500K (288 left) No. of pa ge Fa ul t in FI FO = 16
of th e ne ar fu tu re , thenwe
e re ce nt pa st as an approximation of ti me . Th is approach
417k - (ii) LRU: If we us e th
en us ed for the long es t pe ri od
th at ha s no t be
112k
ee will replace the page cea
pas eee is the Least Recently used
.
tt
a g 2
426k -> No Space Be, {2
Worst-fit: Bi tl iG lall— aia) c 3
a
Ly L4) Lae 3\(3\\3
212k -> 600k ‘\f1) Foltz) e\z\tsilse oO
\ 2\} (2\\8)
ft)c
417k -> 500k (83 lee !E
raUL |
5 Cobb aeehes ES AE
in LR U= 15 aa;
112k -> No Space No. of page fault . pe n s t - ofig time.
page that has not been used
426k Re-> N o Space (iii) Optimal: Replace the
7 us es me mo ry mo st efficient] ot ieee eee
ae es eu shoe Fit algorithms te + x |
y. | ee ; os = Fae 3
is thec a nto ca n th e sy st em do to el im ininate
at sh in g? Wh at 2\\2
th paro“ieblent? use of thra NE ‘ —
a at
a
3 tel ; e\fs} 12]
Ans. Meani
ai 7
" ES iC = i|
4 tinoptimal=11
IfeRthe e Ee| edecnnot uahaeve numb| er of fr "
frames it needs to support
in active fa ul t? Wh at s a e — wo
j Ne ee ad mean by a pase a bl oc k of memory that
use, it will quick ti vi ty is ca ll ed th ra sh in g = « a.
st em wh en 4 pa ge fa ult a ts to acc ess
aeeult notifies the operating
poe nD aare ac w lev el, it sf op er at in g sy ,
In other oe ra ti o de cr ea se s be lo en a pr o Lape
say that when page fault
3
fa ul t oc cu rs wh st or age
? Ans: A page it fr om th e
called thrashing. _
e s 5 ry then tr an sf er
th e ph ys ical me
Causes of Thrashing is not st or ed In memory, thes
}
mu
system that it anst lo ca te th e da ta in
DD or S S to
D th
, e sy st em RA N.
Ae a severe performance problems
i | S| &
device, such
as
Pmeins t
tilization
«
«a :
ee
13+1+15+5+20 |
Average TAT = : = * = 10.80 milliseconds
Process Burst Time Priority |
Average WT =a 9+0+13+1 34 pa
5 4+15 = . 6.80 milliseconds
P2 { 1 (iii) RR (quantum of 2 ms):
Ps 9 3
TAT = CT - AT
(i) FCFS: WT=TAT — aT st .: | 8 20 20 12
P2 0 4 3 3 2
P3 0 B. 5 5 4
| 5
Grantt Chart: fe Pea pees P4 0 4 13 13 9
0 8 g 1.. 16-20
. : | Wan P5 0 5 18 18 13
Process | Arrival Time} Burst Time|Completion Time Tur one THe
0 8 8 8 0 20+3+5+134+18 59
P1
8 Average TAT = 5 ar 11.80 milliseconds
0 1 9g g
P2
P3 0 2 yan 11 AOE 12+2+3+9+13 39 at
0 4 15 15 14 Average WT = 5 7 7.80 milliseconds
P4
P5 0 5 20. 20 15 Q.4. (b) Describe Process State Diagram. (3)
Ans. To start off with the details, a program when needs to be executed goes through
entire operation until
o deck 8+9+11+15+20 63 a process. This process has several state changes in the
= 5 = ; prog ram. Upon succ essf ul term inat ion, the program would get useful
Average Turn Around Time term inat ion of the
user. This entir e proc ess prog ress ion goes thro ugh state changes which
results to the
= 12.60 milliseconds. |
are mention below in steps:
| 0+8+9+114+15 43 | 1.The process enters a state called NEW STAT
E.
Average Waiting 'Time = = 3
RE AD Y ST AT E.
5 5 2. The process then enters the
to an AC TI VE ST A TE /R UN NI NG STATE (Execution of
= 8.60 milliseconds. 3.The process then goes
(ii) Priority (N on-Preemptive): Lowest number yet higher priority. the program starts here).
3 Z | Turn Around | ; |
Process Arrival
(AT)Time Burst
Time(BT) ;
Completion Time (CT) ae Ps Waiting time
WT = TAT- “ (Ws) 7
+ —
P14 Or: 8 13 13 5
P2 : 0 1 1 1
f , scheduler dispatch 1/0 or event wait
P3 0 2 15 15 13
P4 0 4 Be 5 1 /O or event completion
PS 0 5 20 20 15 t h E n t i r e 0 e ration
s t a t e D i a g r am wi e
Fi g . P r o c e s S
22-2017 Sixth Semester, Operating Systems
4.The process ends with the HALT STATE/T
ERMINA LED STATE (afte
program BURST’s are over. The program might be terminated for
terminated normally), cibly op ly LP. University-(B Tech.
LAB Publisher 2017-23
&i repeat
Q.4. (c) What is the role of Medium Term Scheduler?
flagii] := TRUE;
Ans. The use of medium term scheduler is to improve multiprogramm;
multiple processes to reside in main memory by swapping : Dgby ay turn :=j;
eA out procegsseg th at reset
(need I/O) or low priority processes and swap @ while (flag{j] and
ping in other processes that Were ity turn =}) do no-op;
queue. So you can see that we requied medi dium um term scheduler when Nyij CRITICAL SECTION
memory. This swappin g in and out operation does We haya
not take place when We are ty flag{i] := FALSE;
a single small program and have large memory.
: REMAINDER SECTION
Similary if we are running multiple programs and we have very. large Memon,
until FALSE;
than the size of all processes plus addition space for other requirements) then ru
term scheduler is not needed. Modern Information common to both
operating systems
USE Paging go ; edi processes:
Swapping processes they swap pages in and out of memory.It is same as insteas®
a System vi
turn = 0
very large memory(infinite) would not suffer from page faults. | flagi0] = FALSE
Q.5. (a) What do you mean by Critical Section? What are various met flagi1] = FALSE
handle critical section problem? Write a solution for Dining /Phjj hods tb
EXAMPLE 1
problem using Semaphores. , | | S0| DhQj
e
a
ee »
La —
ems
24-2017 Sixth Semester, Operating Syst
bald
i=1, j=0
120, j=l
flag{[0] = TRUE
turn = 1
- Lose processor here
flag{ 1) := TRUE
Philosopher
turn :=0 |
check (flagl0]= TRUE and turn = 0)
Condition is true so Process 1
EXAMPLE 3)
PA ,
ae .
Process 0 ‘6 Process 1
chopstick
i=0, j=1 i=1, j=0 iar
int state[N];
int phil{N] = { 0, 1, 2,3, 4}; LP. Univers;
‘F. University
Tech
-( . B.
|-AB Publisher 2017-27 Ow
test(LEFT); |
sem t t . test(RIGHT),;
iar gare
sem_post( &mutex):
a 49
}
tne test(int panum)
void* philospher(void* num)
| { se
if (state[phnum] == HUNGRY | while (1) {
&& state[ LEFT] != BATING : int* i= num:
&& state[RIGHT] != EATING) | | | sleep(1);
// state that eating
state[phnum] = EATING;
take_fork(*i);
sleep(0);
put_fork(*i);
sleep(2);
| }
printf(“Philosopher %d takes fork %d and %d\n", poene +4, ss +1, Phnun, : ah
printf(“Philosopher %d is Eating\n”, phnum + 1); | om aS
Became Sete has no effec pthread t thread id[NI;
Bring Vake1or | // initialize the semaphores
ee to is hungry philosophers _ . | - + gem_init(&mutex, 0, 1);
uring putior
for (i = 0;1< N; i++)
sem_post(&S[phnum]); | . — sem_init(&S[il, 0, 0);
} | NR . : | for (i = 0;i1< N;1++) |
| 2 , | // create philosopher processes on
Bogen ices | , | NULL,, philospher, &philli);
pthread_create(&thread_id{i]
SOE ERE MOISE SU) | | "2 printf(“Philosopher %d is thinking\n",i+ 1);
( oe 7 |
sem_wait(&mutex); , i. for (i = 0;i< N;i++)
// state that hungry : | ? a pthread_join(thread_id{i], NULL);
state[phnum] = HUNGRY; | ‘a. | Me (4)
printf(“Philosopher %od is Hungry\n”, phnum + 1); | “< Q.5. (b) Discuss Dekker’s Algorithm. ger eda
// eat if neighbours are not eating test(phnum); | | aL. Ans. Dekker’s algorithm was = ae - a 2 and an integer variable:
sem_post(&mutex);
problem. vaIt requires both an array
//if unable to eat wait to be signalled r flag: array (0..1) of boolean;
sem_wait(&S[phnum)); Raev ks turn: 0..1;
rig yee e en repeat
| ae | | flagli) := true;
// put down chopsticks
void put_fork(int phnum) ‘t | while flagti] do
if on
sem_wait/( &mutex): : ae a flag{il := false;
//state that thinking while turn = j do no-op;
state[phnum] = THIN flag[i} := true;
KING;
printf(“Philosopher %d putting fork %d and %d a end; i
print
;
f(“Ph
“
iloso
;
pher %d is thinking\n”, phnudown \n”,
m + 1): Se
hn L ¥ i os :
+) LEFT +1, “3
4 | arr cas
, 3 i urn = Jj;
_"
26-2017 Sixth Semester, Operating Systems
: e
int state[N)]; *
int phil[N] = { 0; 1,2;3,4 iF | | siontttt LP. University-(B Tech. |_AB Publisher 2017-27
sem_t mutex:
eadpetr
sem_t S[N];
; oid test(int phnum) ee
void* philospher(void* num)
if (state[phnum] == HUNGRY
| 7 " while (1){
&& state[LEFT!=
] EATING _ int* i=num:
&& state[RIGHT] != EATING) { | ig sleep(1); :
// state that eating take_fork(*):
| state[phnum] = EATING; sleep(0);
put_fork(*i);
sleep( 2); | ; }
| J
printf(“Philosopher %d takes fork vA and %d\n’”, pheam +1, ae +1, Phnum , | |
printf(“Philosopher %d is Eating\n”, phnum +1); I, int main()
3 4 . (
t
26-2017 Sixth Semester, Operating si cp:
int statelN):
int state[N]; LP. Universit -(B.T
int phil[N] = { 0, 1, 2, 3, 4); Y-\B.Tech.|-AB Publisher 2017-27
test(LEFT);
_ test(RIGHT);
sem_t mutex;
sem_post(&mutex);
sem_t S[N];
void test(int phnum) est
void* philospher(void* num)
| | { .
if (state[phnum] == HUNGRY ; ae {
&& state[LEFT] != EATING
* 1=num;
&& state[RIGHT] != EATING) | | oS ‘aie
// state that eating | 3 |
|
| | 7 salt (*1);
_ State[phnum] == EA EATING;
put_fork(*i):
| | \
sleep(2);
|
sem_wait(&mutex); ae begin
//state that thinking
- flagtil a sit
E while turn = ) © No-OP;
state[phnum] = THINKING;
y flag{i] <= true;
Pantit"Philosopher %d putting fork %d and Yd do a a
printf(“Phil
“DL; osopher %d js thinki
| ng\n”,
end; )
i phnum wn+ \n”,
1): phnum ! + L: LEFT + +1, ho » Lae ) critica
ae l section
.
turn :=j}
28-2017 g:
ixth Semester, Operating Systems
flagli] := false;
remainder section
until false;
UNIT-III ‘
Q.6.(a) Consi Onsider the following snapshot of a system. All resources are remqueste
Sted at once
« In some cases pree
: n
Process: All ocatio Max Available Avoidance: Pts More than often necegs
A B a A a C iz 5 « The cal for deadlock avoid , =
0 | é * Deadlock avoidance ig of ance is to th
PO
1 0 1] 5 3 3 3 ae ° The system requires ade “1 Impossibl
P] use of each resource for each oe apriori inf
0 2 0 0 3 9 2
0 9 e In order for the syatita tei
3 0 3 9
2 2 or unsafe, it must know in Scae, a
9 1 1 9
PS
available, anncdre chnia«any time the numbe T and type of all resources in
existence,adlo
P4 | | OR a2 4 3 3 e De ck avoida te
0 A es include B ;
it ete
: : g ‘hig e Resource allocati © Sanker’s algorithm, Wait/Die Wound/
A ad the foll ow in g questions usin Banker’s algorithm. ; on str
;
:
the . (By that of detection and pdeecikion gy for deadlock avoidance selects midw ay between
Gi) s8 System in a safe state? |
* Needs to be manipulated until at]
oa - east from process P1 arrives for (3,3,0) can the request be atleast one safe path is found
iately? Granta, « ‘There istic piéewniiion
| Q.6. (c) How can the no-preempti
|
Ans,
d? em pt io n an d ci rc ul ar wait conditions b
prevente 3)
Pro cess ae Max Available Nessa . Ans. No Preemption
>
Preemption of process resource allocations can pre
:
7
A B C ABC ABC
/ | _ le.
when it is possibp Prevent this condition of deadlocks,
PO 010 753 322 | o One ap ris if a process i
thact h
oa :
| 743 new resource,
a ng
P : 129 then all ot he r re so ur ce s iv ed ia ua ty fa a Ah a ae
s
Fequesti
are imp lic itly released,
322 ed ), fo rc in g thi s pr oc es s to re- ac oe es pr oc es
| : 200 | (preempt
P2 302 902
P3 211 99:9 | 600 -_—‘ resources in a single request, similar tothe widest Ss aan eS
o An ot he r ap pr oa ch i eces
A ‘OLs
rs sis guatens aes — = nis in a re so ur is requested. and not available, then
P4 002 433 |
cee er processes currently have those resources and are
themselves blocked waiting for some other resource. If such a process is found, then
(i) The content of the matrix need is d efined to be MAX — Allocation
i ai
and isaboy, .. some of their resources may get preempted and added to the list of resources for which
We claim that the system is currently
) i in safe state. the process is waiting.
P4, P2, PO> satisfies the safety criteria. i ? ate: ndced, Use sedate <P1, P3 Fither of th states are
: o Either of these approaches may be applicable for resources whose
Gi) You should:he ablettace
in this statendt easily saved and restored, such as registers and memory, but are generally not applicable
request fon'(6 310) betPe cian me however, that, when the system is not availa i to other devices such as printers and tape drives.
ecnicel 2 aig ire Se i ae since the resources are ;
cs — ie oe
granted, even though the resources are available is to number all resources, an to require that
since the resulting state is unsafe. e One way to avoid circular wait
our ce s onl y in str ict ly inc rea sin g ( or dec rea sin g ) order.
(b) What isi the di: fference between deadlock avoidance and prevention? processes request res
Q.6. b
s, in or der to request resource Rj, a process must first release all Ri
4 e In other wo rd
Ans: SE ili such that1 >= 7 oe
(3)
| 2 a foe
s sc he me 1s de te rm in in g the re al y ordering of the
¢ The HS laomcse 7
- . ce in thi
0 of th e ne ce ss ar y co nd it io ns for deadiaal
1s to ensure that at least one 0 to 199. The
never Renae drive ha s 20 0 tr ac ks nu mb er ed
Q.7. (a) Suppose that a disk mb er 100 . Th e re qu es te d tracks,.
eadlock prevention is often impossible u est at track nu
'18,90,16 0,38,184. What is
- :
1 a
.
39 58
18
90
ee
, et alas 184 Total distance in LOOK
The total distance in (160 — 100) + (184 - 160) + (184
FCFS: _ 90) + (90 ~ 58) + (58 —55) +
(100 — 55) + (58 — 55) + (58 — 39) + (39 — 18) + (90 — 18) + (55 — 39) + (39 — 38) + (38 — 1g) - 25
0 cylinders
(160 — 90) + (160 ~ 38) + (184 — 38) = 498 cylinders. Ti Q.7.(b) What are various parameters
for evaluating Disk performance?
(ii) SSTF; scuss. :
Ans. Higher performance in hard disk (4)
drives comes from devices which have better
0 18 38 39 55 58 90 100 performance characteristics. These devices include those with rotating media,
160 184 199 hereby
} i 4 7 Fazwosd | T 1 called rotating drives, i.e., hard disk drives (HDD), floppy disk
| drives (FDD), optical
100 discs (DVD-RW / CD-RW), and it also cover s devices without moving parts like solid-
state drives(SSD). For SSDs, most of the attributes related to the movement
of mechanical components are not applicable, but the device is actually affected by
some other electrically based element that still causes a measurable delay when isolating
and measuring that attribute.These performance characteristics can be grouped into
- two categories: access time and data transfer time (or rate).
The total distance in SSTF: Access Time:
The access time or response time of a rotating drive is a measure of the time it takes
(100 — 90) + (90 — 58) + (58 — 55) + (55 — 39) + (39 — 38)
before the drive can actually transfer data. The factors that control this ee om .
_ + (38 — 18) + (160 — 18) + (184 — 160) = 248 cylinders rotating drive are mostly related to the mechanical nature of - rere ape ss
moving heads. It is composed of a few independently measurable eleme
nce of a storage
0 18 38 39 55
added together to get a single value when evaluating the performa
+ | bie 58 90 100 160 184 199
= 1 T T T
| device.
T T + + er to obtain the access time
The key components that are typically added togeth
} }—
. 100
uge 184 are:
199 | e Seek time
—<—
e Rotational latency |
39 55 :3 (8 2 ~ e Command processing time
38
eer
18 e Settle time
Total distance in SCAN:
internal
(160 ~ 100) + (184 — 160) + (199. Transfer Rate:
covers ee Se
oe
t a t
-The = dgta.trg as nate of a drive (also called throug hput)
< disk surface an d the con t system).
eo
ee pe
ee SEP
bee al
extern mee
rate
da ta tr an sf er ra te wi ll be the
- The measurable
1s
sited
1” al la te nc y
e i si 98 90 100 160 184 199 Q.7.(c) W h y ro ta ti on
! | |
position informa
to
th re
e host.
160
. tion
al
a,
| ' |
xp their rotati
;
184
ee
Ev en if th
EPO
18
38 39 65 5 %
imprecision and the time C0
et
eae
:
;
ftrns
7:
32-2017 Sixth Semester, Operating Systems
Position information woul
d become incorrect. Furthe
given in terms of logical bl r, the disk "equegt,
ock numbers, and the mapp
Physical locations is very ing between logica) arbi, ly, |
complex.
4
L.P. University-[B Tech.
|_AB Publisher
t Advantages:
UNIT-IV | Both the Sequential and Dire
Q.8. (a) Describe various file > the address of the kth, block ct Accesses are supported by th
is. For direct access
allocation methods. Compare ich starts at block b can easily of the file wh
index allocation with contiguo an d, be obtained a
us file allocation scheme, (b + k)-
| | “ony, This 1s extremely fast since the nu
Ans, File Allocation Met mber of seeks are minimal because
hods | contiguous allocation of file bl of
7 stored in the di Disadvantages:
ocks.
thr ane allocation methods def ine how as sitie os Z = Plocks, Ther, |
wee Main disk space or file allocatio ¢ This method suffers from both int
n me ernal and external fragmentation. This
—* Contiguous Allocation a ¢ inefficient in terms of memory utiliz makes
ation.
* Linked Allocation ‘am? ‘© Increasing file size is difficult because
it depends on the availability of contiguous
* Indexed Allocation |
memory at a particular instance.
Thehiemain idea7 behind these methods is to provide: ) 2. Linked Riek Siceaston ‘Soe
sstheasie ) | — In this scheme, each file is a linked list Te,
of disk blocks which need not be contig) uous.
“Micient disk space utilization. . a " The disk blocks can be sca
ttered anywhere on the disk.
| | . The directory entry contains a | bee aes
* fast access to the file blocks. pointer to the starting and the ending
All the three methods have their own Each block contains a pointer to the file
next block occupied by the file.
.
ae ee
; Th
1. Contiguous Allocation * t block (25) contains -1 indicating a null pointer and does not point fo any o
| : las
In this scheme, each file occupies a cont pt
: iguous set of blocks on the disk. directory .
if a file requires n blocks and
assigned to the file will be: 6, b+ the hl... file start end
, 6+2,....6+n-1. This means th |
block address and the length of the file (in te at given the startin, ieep 3 25
rms of bloc ks required), we can determin 1 4] of] 3
the blocks occupied by the file. 0 1 3
: | +
* Address of starting block
* Length of the allocated portion.
The file ‘mail’.in the following fi | es |
gure starts from the block 19
: : 7 Therefore, it occupies 19, 20,
21,22, 28, 24 blocks. with length =6 blocks 12113 “F SL
18[_\17(_}181_J19
i ee ae i ) 20(_J21 EF J22 23}
count | file, Start le length i ae
OL 12) 2L) 3 oal_j25t 126127
count 0 2
4 5 6
f ;
7 [es i 14 3
30|. 131
mail 19 6
S 29 ,
8 9L_}10{_ /414
: list 28 4
tr am f 6 2 ) ; d easily since
ia 3 Advantages: spe t be in cr ease |
21131140) 15 0 f fil e si ze . Fi le si ze ca n
e This is very pee .
in terms 0
for a contiguous = rf a memory.
18/17 }1sCjige ee t This makes it relatively
tem does not heve fragmen
yy _mail Oo S
20L-J21_J22[ Jos a me ma method does not re eal
better in terms of memory 4 om
es
24l_J25[ ]26[ 27 Disadvantages: he disk, a large number of
; di st ri bu te
* Because the file blocks eae :ndividuall d ra nd om ly a linked allocation slower.
. list f y. This m at directly access the ae
seeks are ne eded to access ete or direct access. We | is
26_J20lJs0L2 oN
n sequential
: ly (sequen
(iii ) Whe
O
is in de xe d by us er na me or Ac co unt Number.
is searched. MED articular file, only hisis 0 own UFD D i is seare hed. |
ae
(iii) Whe n user refers to a part Orato aene’ To havea pattie ye fila
Thus different users may have file s wit! same and file NAMe.
y ‘rectory , we must give both tree the user
uniquely, in a two level directory. od of height 2
ve l di re ct or
, y ca n be a tr ee or an invunvert
Comaprison: A two le L
| is Ma st er Fi le Directory (MFD).
Index Block All The root of a tr ee
). Th e de sc en de nt s of UFD’s are
FD
ocation e User File Directory (U
ar
1. File block add Its direct descendents
resses file themselves.
2. Directory has a p the le av es of th e tree.
ointer to index blo _ The files are
3. Both random and se ck ve l D i r e c tory
. Limitations of T w o Le
quential accesg u s e r f r o m another.
4. .File size limi tation depends 0 “areLe easy st ru ct ur e ef fe ct iv el y 1s 0 lates o n e
8
The
he j index
inthe block then the maximu,, size f
Nn array file
« ne ree we have (ae pointe ae
A (3) Tree S t r u c t u r e d Di re ct ory
files or s ub di r e c t o r i e s . A\ l d irectories
blocks a.set of
KB assuming 1KB dat 5 A directory (or Sub directory) contains
th e s a m e in te rn al fo rmat.
has y d e f i n e s t h e entry.
ch di re ct or y e nt r
(i) One bi t in ea t e d i r e ctories.
ea te a n d d e l e
ll s ar e us ed to cr
(ii) Special ca
36-2017
Sixth Semest
er, Operating S
Bach pr eeess ha
4
ystems
. > “
s a current direc
'S that are tory. Current dir ctory
of c“utrrree
nt in terest to the process. e Sho
u Iq “Ona
(iv
Ie) ) When
|
ar bferanc .
€ is
, u The user chn change made to a file, the current directory is s earch
LEU Niversj ty-[
B Tech, }~
his current di rectory whenever he de \ why it is vital that staf
cnattne, whe sip f Members with System
file is hot needed in
the current directory So and upload ciiiue ace |
iY = path name or change tnen the user Usual There are several steps to
the current directory. * Meee nae be consider when train
4ths can be of two an active, Evolving proc
(a) Absolu te Pain types :- y "ty : bie yeorunderstand ess it response to operational needs
document with procedures sh
| *| ae z |tem ad ould be readily available for
Be
: gi
gins
ns at ro
. ot and follows a = maa umirni
eshould assign Correct le
path down to t he specified file vel of access to users ba
(b) Relative Path Pp j ie sed on
is
- Auditing Processes |
Defines a Path from curren should be put into pl
t directory. accountable for any inac ace so that individuals
_ curate data entered into can be held
(v2) Deletions ir dire | Data Validation Rules th e sy st em .
ctory is empty, its en
simply deleted. If it is not em try in the dir ectory
pty : One of the Two approach that Co a
(a)User must delete all the files in es can b Ntaing. place, there is always room for
the directory. human-error
ntry in their 9
(b)If any sub director : . | rules, administrators can ensure d
ies exist, same procedure must be appl
The UNIX rm co ied. Be
mmand is used. alteration, validation rules provide addition al
. security and data quality assurance - a
MS dos will not delete a directory unless it is
empty. natural requirement for accurate analytics.
(4) Acyclic Graph Directory ay Q.9. (a) An operating system only Supports a
| single directory but allows that
Acyclic Graph is the graph with ae directory to have arbitrarily many files with arbitrarily —
no cycles. It allows directories file names. Can an
and files. With a shared file, onl to Shargye g: ae approximate hierarchical file system be simulated? How?
y one actual file exists, so any (4.5)
Person are immediately visible to the another
changes Made } by i Ans. One way to simulate that is to append to each file name the name of
Implememtation of Shared files and di directory that contains it.
rectories an For example: UsrStudentsZivaPrivateFileX
G) 7 create a link sine fil 7
“Hierarchical File System” (HFS) is the file system used — ae eae
ce
A link is effectively a pointer to another
file or Sub directory. Macintosh hard disk. When a hard disk is paren a = a tae
Duplicate all the information about them an = archical file system is used to create a directory £ a Pras Oe ace
1 n both sharing directories
(ii) Deleting a link ae ice
O are added to the disk. Since HFS is a Macintosh fo >
* Deletion of the link will not effect th ves.
ann ot recognize HFS-formatted drives. icallyly formatted
W WindowWw s hard drives drives ar are typical
e original fj le, onl y link is removed ee using WIN32 or NTFS file systems.
To preserve the fi le until all references to it are =i
deleted. | oh i : ot originally designed to handle large hard disks,isks, such as the
ae eee as oe ein today,
dated file system
Apple aah eae a = allaes for smaller
ie x : r HFS Extended, with the release of Mac’ = Y file must take up. This
qual cluste nahi
ae sizes, which reduces the minimum size
ain data during collectig.
automating processes,
delegating tasks, an ee rating 8}
strategy i for The ries of bytes. Thisbare pla roac
Maintain data quality t d monito ring data cleanup,
hroughout its life-cycle. F
DIG hel systema 2 “d instead treat all cae the operating
ture for
_ Data Entry Training & Accountabjj; ae 7 ee ee The advantage approach is that 1) SIP. de the struc
© er has to provi
ty system no long file struc tures,
Data integrity Starts
at the source — the user vo Ma i - system supp ort for file systems: ees applications to define
errors that compromise analytical
; : Manual data entry can vba i} , Furthermore,
|
results meant to guide business different file types
m S
Ss.
decisions. Thal
38-2017 Sixth Semester, Operating Systems ;
alleviating the situation where a system
may not provide a file definition Fe 4
specific application,
Q.9.(c¢) Deseribe file access control mech e
anism. : an
Ans : Access control is a security technique that ca
ch
TONIC ke,
i
i | sf ¢
Ne
|
tp.
F!
yt ; Re 7
7
rh t ,
[B.TECH]
. 1% hrs. LETCS-304]
30 MLM. :
Iwo te: Attempt Q.No. 1 which is compulso
ry and any two more questions from re
maining.
Q. 1. (a) How Timesharing is different from multiprogramming ?
(2)
Ans. Main difference between multiprogramming and time sha
ring is th t
E, ,ltiprogramming 1s the effective utilization of CPU tim
e, by allowing several ra a
“sp use the CPU at the same time but time sharing is the sharing
of a oldman facility
by several users that want to use the same facility at the same time. Eac
h user on a
=F time sharing system gets her own terminal and gets the feeling that she is usi
ng the
s |} cpUalone. Actually, time sharing systems use the concept of multiprogramming to share
the CPU time between multiple users at the same time.
Ae
Sh
ce24 9.1. (6) Differentiate between Internal and External fragmentation.
Ts
ay
r (2)
| _
+ Ans. External Fragmentation: Total mem
ory space is enough to satisfy a request or to reside a process in it, but it is not
| contiguous so 1t can not be used.
Ope rating system
se Process 7
Process 0 3
Process4 |
Internal
fragmentation
External
fragmentation
si ze t h a n th e p a r t i t i o n m a
j
"i with le ss
jp AP
a ar ——
zl
i 4 a
|
2-—2018 Sixth Semester, Operating System
adjacent orl . LP. University-(B.Tech]|-Akash Books
unusable. External fragmentation is due to the lack of enough Process
ause then ajj fr CR ay
loading and unloading of programs or files for some time bec ‘ty C€g Pay | CPU burst time |
:
Arrival Time
;
: re.
ant buted here and the P
distri 1
: 9
ed by com pac
.
tio n whe re the AaSSignea,.
.
P
¢ External fra gme nta tio n can be min 2 6
. : , so that contig ; s
uou spa ce :
18 841 ined. However, thi OP eratio
9S
ed bI
n we P 2
are moved to one side
;
s 4é 4;
time and also certain critical assigned areas for example system services can, ty
dis ks whe n running: t iy
obs erv e this com pac tio n step don e on har d
moved safely. We can 3
i ‘ Ps 2 4
disk defragmenter in Windows.
. External fragmentation can be prevented by uae th Sa oe Segment, i: Ans. (i) SSF
SP eiven While in realy tig, font
and paging. Here a logical contiguous virtual memory Preeee ce BT
files/programs are spl itted into 2spar ts and pla ced
res
here8 and theFoe 4 Ytthe aE AT.
I —l=2=1=1-1=x 9
Several size, |
e Internal fragmentation can be maimed by mijn ner ) Po 6-1=5x 9
erna agmentation;,
assigning a program based on the best fit. However, still int
od? Kixplai ae i Ps 4—1=3-1=2-2=x 4
fully eliminated. 6
- xplain with diagran, Poi? 5
Q. 1. (ce) Why medium term scheduler is require
g
Ps 2%
(3)
Avg. waiting time > O+74+05 +9+0 _ 465 3.2 unit time.
for P, 3 0+3=3
Term around time —
P, —> 7 i 6 = 13
P, > 9+ 5 =14
P. +0+2= 2
x, Ave. LAT = 36/5 = 7.2 unit time |
¢ Scheduling can be application specific in the user level thread. | Pp, b- eyo
. , e.
4.6 Unit-tim
are fast to create and manage.
Jae | = oye . sete {0
ae e Us
zaer sis ae
ae Avg W.t = a
* Ina typical operating system, most system calls are blocking. | +s foe BO +3=3
¢ Multithreaded application cannot take advantage of multiprocessing. Turn around time . age
Q. 1. (e) What is thrashing ? Explain why it occurs. (2) | | | 2 +» 5+4=9
Ans. Refer Q.no. 2(c), End Term Examination 2017. P.No.- 16-2017. oe ) »71+5= 12
-
| : 4
; er Pp? 10+2=12
Q. 2. Consid the set of processes P, to P, with the following CPU burst |
time.Find the average turnaround time and waiting time for Shortest Remaining |
job First and FCFS scheduling techniques. | (10) |
Sixth Semester, Operating System |
4—2018 LP. University-[B -Tech|-Akash Books
2018-5
> 3474941
: 2412 = 48
= =86 Unit time. : . . 4.4 process contains a logi
cal address space of 4050 bytes. Main memory
Avg of of t.0. t. age 1S oe bytes. If the process is divided i nto fixed size partitions of 16 byte
pic” (10)
Q. 3. (a) Why are segmentation and paging sometimes combined int | (a) What will be size of offset/displacement bits?
scheme ?Explain with suitable diagram. * (b) How many pages are there in the process?
a
Ans- Segments can be of different lengths, so 1618 harder . ae ce - Asan, | (c) How much internal fragmentation will occur?
in memory than a page. With segmented virtual memory; oe fi sical tone S of yj E (d) Find out number of entries in general page table.
ges
memory but we still have to do dynamic storage allocation of phy Ory. In op (e) If the page table in inverted one then how many entries will be there?
; ing
paging
into a two-0-leve] Vittyy
ah) | |
to avoid this, it is possible to combine segmentation and = 24
: pa ge table for that advsegmen; Ans. (a) Page size = 16 byte
memory system. Each segment descriptor po in ts to
ment) with some of the anta Go, number of bits in page offset is ‘4’.
give some of the advantages of paging (easy place Be9 (b) The no. of page in the process
segments (logical division of the program). | ae
such as aa at thy) = 4050/16 = 253.125 = 28
Paging is a virtual memory scheme which is ods tlecka
Yteg, | (c) Page size = 16 byte. process size = 4050 byte
‘din |
application level and which divides memory into i Fae So. no of pages = 253 pages + 2 byte. So internal fragmentation
The segmentation memory management scheme PO rane
ee
using segme e size, = 16-2 =8 byte.
burden on the applic ation, and refers to memor y
ica l uni t vis ibl e to the use r’s pr og ra m and id of arbitary Size (d) No. of entries in page table = No. of pages, the process divided,
Segmentation is a log
uni t inv isi ble to the use r’s vi ew an d is of fixed size so no of entries is 2.
whereas paging is a physical
(e) No of page = 2° |
bit.
trap So the no. of bits required to identify each page = 8 |
— 210 /94 = 9® ,
2
no o. of fr am es
numbers 8 pr es en t in each frams:
wil l st or e pa ge
-segment table > inverted page table we
STLR . nu mb er s of en tr ie s will be 8:
so the
3 yes > :
STBR PTBR
S : :
: physical
CPU -}—*® (sd) page ieee memory
E p
(p,0) f -— (f,0)
|
Q. 3. (6) Calculate total number of page fault that will occur while processing
the page reference string given below : 4,7,6,1,7,6,1,2,7,2, using LRU page
replacement policy, when page frames are three. , 6)
he the Be ae e vv
x x x x
END TE RM EXAMINATIO N F re cu e 20 18 , c
of this p
ode/data in
RAM.
2018-7
Disadvantage
a te *,¢6
Ans. There are many different criteria’s to check when considering the Ans. Paging is implemente 4 2018-11
by breakin
scheduling algorithm : tis most efficient to break th ‘Ng up an address into 4 page and
erform arithmetic on the © address into X page bits and Y idle
1. CPU utilization: To make out the best use of CPU and not to waste
cycle, CPU would be workin| g most of the time
| (Ideally 1000%% ofof the the titime). Cons a) Cby
ide
real system, CPU usage should range from 40% (lightly loaded) to 90% (heavily load
2. Throughput: It is the total number of processes completed per unit + Y
rather say total amount of work done ina unit of time. This may range from 1O/seey.” Pe cvcvcccccvrete oeh eS ev ese sedinadunctbes WP ot
ek delcscdetcnc,
to 1/hour depending on the specific processes. nd | Page number (n
bits) | byte offset S
au
3. Turnaround time: It is the amount of time taken to execute a particular Pre of cacataccesduaaO
eeE
ceE
tec +
i.e. The interval from time of submission of the process to the time of completion of 88,
process(Wall clock time). the
4. Waiting time: The sum of the periods spent waitinga in the ready queue
of time a process has been waiting in the ready queue to acquire get control on theAmMOunt
Cpy
|
|
5. Load average: It is the average number of processes residing in the ready q
ueye
waiting for their turn to get into the CPU.
6. Response time: Amount of time it takes from when a request was subm itteq
|
until the first response is produced. Remember, it is the time till the first respons 8 and
Q. 4. (a) In the context of process schedulin
not the completion of process execution (final response). : :
starvation occur under the following aateaiauce what is the starvation? ~
In general CPU utilization and Throughput are maximized and other factors
are (i) FCFS (ii) SIF
reduced for proper optimization. (iii) SRTF
(iv) Preemptive priority based (v) Round Robin.
UNIT-I 3 Ans. Starvation is the phenomena in which
Q. 2. (a) Discuss the various memory management schemes. (6.5) a process is not able to acquire the desired
resources (like processor, I/O device ete) for a very long time to progress with its exe
Ans. Operating system versions Vista SP1 and Windows Server 2008, impleme ted cution.
This can happen due to drawbacks of scheduling algorithms. Scheduli
new technologies, for both resource allocation and security. Several of these new ng algorithms
are used to decide to which process the resource(s) needs to be given next. Example:
technologies include the Dynamic Allocation of Kernel Virtual Address Space (including
e In Shortest Job First Algorithm, if there is a process with a rather large CPU
paged and non-paged pools), kernel-mode stack jumping, and Address Space Layout
burst waiting for its execution and a stream of processes with smaller CPU
Randomization. Basically, the allocation of resources are not fixed, but are dynamically
burst keep entering the ready queue (a queue consisting of those processes which
adjusted according to operational requirements. The implementation of these new
technologies such as Address Space Layout Randomization are mostly due to the are ready to execute), then the CPU will always be allocated to the process with
hacker the shorter CPU burst and there is a probability that the process with the large
threat of an advanced knowledge of the location of key system components
(such CPU burst might never get the CPU to complete its execution and starve.
as kernel32.dll, ntdll.dll, etc), and are partly due to the Window’s goal of
using memory e In Priority Scheduling, a constant stream of high priority processes might starve
allocation more efficiently by allocation on an as needed basis.
In order to understand one or more lower priority process(es) as the CPU will always be allocated to
these new technologies better and be able to use them as a dev
eloper, device driver writer, the process-with highest priority. |
or systein’s administrator, |
x
Waiting for something that will eventually happen (in deadlock it will never happen).
First-Come First-Serve Scheduling, FCFS ha
is very simpl e - Just a FIFO queue, like cust omer s waiting in line at the
¢ FCFS
bank or the post office or at a copying machine. Be
¢ Unfortunately, however, FCFS can yield some very long a =
- particularly if the first process to get there takes a long time.
Q. 2. (6) Explain difference between consider the following three processes:
internal and external fragmentaliaas Process Burst Time
| 24
(3) Pl
Ans. Refer to Q.1 (b) First Ter :
m Examination 2018 Pa. .
Q. 2. (¢) Why page size is always a
: 9 , : )
pages, frames and page table
? npn ar ri veos i e
fir st. Th e av erag e waiting
a? Ie PARAS scheming. Maes 8)
G a n t t <ch ar t be lo w, pr e cess Pl
. first 44+27)/3=11
5
r th e t hr ee pr oc es se s is (0 + 2
ae fo
12-2018 Sixth Semester, Operating System
In the second Gantt chart below, the
time of (0 43 4 6 )/3=3.0
same three processes have an ay LP. University-{B Tech|-Akash
Books SH’s
:
same, but in the second
ms. The total run time for the thr
My e Q Ure “Tagg estimate[i+1}= alpha * bur stl i
, S .
case two of the three finish ts) ie
process is only delayed by a short amount. much quicker. and th ty
: * Oh
P, P, | fi
0 3 6 7
FCFS can also block the
system in a busy dyn amic
as the convoy effect. When one CP system in another Way
U intensiv
of I/O intensive processes can get backed e process blocks the CPU, 5 Ry
wae up behind it, leaving the 1/9 4 be
idle. When the CPU hog finally relinquishes the CPU, then the VOOdie.
pass through the CPU ; ;
quickly, leaving the CPU idle while everyone r >i |
tte,
for I/O, and then the cycle repeats itself when the CPU inte ‘ Ueg
back to the ready queue.
Shortest-Job-First Scheduling
, SJF
* _ The idea behind the SJF algorithm is to pick the quickest :
needs to be done, get
fastest little
it out of the way first, and then Pick the next JOb tha
fastest job to do next.
ae |
Sm al le g, |
* (Technically this algorithm picks a process based on t he n
ext shortest CP
burst, not the overall proce
ss time.) y
* For example, the Gantt chart below is based
upon the following CPU burg
times, (and the assumption that all jobs arrive CPU burst (2) C74) 6.4. @ “W
at the Same time.) -x
Process "quess"(t) 705 6 6 6 §: 9 WR
Seis: Burst Time
ir | 6 Figure -- Prediction of the length of the next CPU burst.
P2 8 SJF can be either preemptive or non-preemp
- ?
tive. Preemption 7 when a
occurs
a} apts 7 new process arrives in the ready queue that has a predicted burst time shorter
P4 than the time remaining in the process whose burst is currently on the CPU.
| 3
Preemptive SJF is sometimes referred to as shortest remaining time first
scheduling. 3 | |
LEONA LORI eae
& SS ee ORTne .
Oe
eS <>
hk
Taig " Ee . St
eae
For example, the following Gantt chart is based upon the following data:
Process _ Arriv‘ al Time
i t Time
=
ge wait time is (0+3+4+9+16) 0
opposed to 10.25 ms for FCFS /4=7.0 ms, (as Pl ;
for the same proc esses. )
P2 ‘
P3 5
re 1s n© 3 a
; e
es eee
14-2018 ere or small numbers. This book uses low number for be
use large en 0 being the highest possible priority. Igh
pee 'e. the following Gantt chart is based upon these process burst tj
time of 8.2 ms: Mes
> =a S HerTtiOss and yields an avereee wae
Process -Burst Time Priority
Pl 10 3
P2 1 1
P3 2 4
cach© process gets 1/nth of the processor time‘ude
r -se Borithms
P4 1 5 and shar Ifit is y
P5 5 2 wf, a real SY
stem invokes overhead for every context sy
He5 eoyantum
petween 10 and 100 milliseco
ads
nds, andare.context
Most
swine =m
qu 4 microseconds, so the overheais
d small relative tithes oo on the order
0 1 6 AAG 18 19 of process time = 10 .
q >4 :
:
ao
ar
+
-
Se=>
=
~
S.
a
Wo. y
Se
“<p,
-. ~e
Jie
on
be
.
Fos
“2S
'
. < ea 5 Om et * ET ya:
. 4 ws t * 7
> One common solution to this problem is aging, in which priorities of jobs
12.5 bs
7 2? - -s . : ail 2 so!
og tee ae a
- a - rs
roa ~ on &
7
increase the longer they wait. Under this scheme a low-priority job will
7 e Lad a
eventually get its priority raised high enough that it gets run. | 12.0 ey
oO WA pe ER. ak
When a process is given the CPU, a timer is set for whatever value has been set
for a time quantum. ex 10.5 Ree
ke Sake 8
oO If the process finishes its burst before the time quantum timer expires, SoO 10.0 PaesSere bana
chen it is swapped out of the CPU just like the normal FCFS algorithm.
SaaS ED
D
_ ~
aes ~ '
i Suk
mend
Dees
a .
=c 9.5 Fe en LBs ss
If the timer goes off first, then the process is swapped out of the CPU and
by poe *s : yore |
eee a a
°
; a ax Ss , Pot a
The ready queue is maintained as a circular queue, so when all processes have
YEO RS Sve es i > rs
fe e bs ee
had a turn, then the scheduler gives the first process another turn, and so on: ToC es
RR scheduling can give the effect of all processors sharing the CPU equally, Geo"
although the average wait time can be longer than with other scheduling vantum the time 484 *
algorithms. In the following example the average wait time is 5.66 ms. . und time ' | 7
|
Figure - The way in which turnare
a
~aN es =) i Dee
Priority
.
FI am
evety process, the short term schedule . At the reine
r schedules the process with the least
burst time among the list remaj,: : a1 ¢ P3 PS Ps P2 7
of available processes and the runnin
Once all the processes are available in the
g process.
ready queue, No preemption wil] b
oe 2 3
10 16 22
Ea
39 45
done and the algorithm will work as SJF Avg Waiting Time = (04+14+0+7 +1+25+16)/7 = 63/7 = 9 units
scheduling. The context of the procegs ig
in the Process Control Block when the pro selva starvation or indefinite blocking is phenomenon associated with
cess is removed from the execution and the the Priority
duling algorithms, in which a process ready to run for CPU can wait
next process is scheduled. This PCB indefinitely
is accessed on the next execution of gche of low priority. In heavily loaded computer system, a steady stream of higher-
this Process.
Example: In this Example, there are six jobs P1, P2, P3,
P4, P5 and P6. Their arriya}
pecause
rority processes can prevent a low-priority process from ever getting the CPU.
time and burst time are given below in the table. Pq.4. (b) Consider the following set of processes with the length of the CPU
rat time given in milliseconds:
Process | Arrival | Burst |Completion | Turn Around Waiting Respon , P - Process burst time priority |
ID Time | Time Time Time Time Time e Pl 10 3
1 0 8 20 20 12 0 P2 1 1
2 1 4 10 9 5 Tots P3 2 3
3 2 2 4 2 0 2 Pp4 1 4
4 3 1 5 2 1 / 4 P5 3 2
5. 4 3 13 9 6 10 m The processes are assumed to be arrived in the order pl, p2, p3, p4.and pd
6 5 2 : |
7 2 0 5 all at the time 0.
4 Avg Waiting Time = 24/6 . (;) Draw the Gantt chart illustrating the execution of these processes using
Preemptive Priority Scheduling: FCES, SJF, non preemptive (a small priority implies a higher —
| (4)
In Preemptive Priority Scheduling, at the time of arrival of a process in the ready
Round Robin quantu=m1 scheduling.
process for
queue, its Priority is compared with the priority of the other processes present in (ii) Calculate the waiting time and turn around time for each
the (2)
SRTF strategy.
ready queue as well as with the one which is being executed by the CPU at that point of
time. The One with the highest priority among all the available processes will be given Ans. (i) Gantt Chart FCFS:
the CPU next. D4 P2 | P3 | P4 PS
The difference between preemptive priority scheduling and non preemptive priority ; 10 1% 13 14 N
scheduling is that, in the preemptive priority scheduling, the job which is being executed
SJF:
can be stopped at the arrival of a higher priority job. :
Pt
Once all the jobs get available in the ready queue, the algorithm will behave as non- p2 | P4 | P3 PS { 19
preemptive priority scheduling, which means the job scheduled will run till the completion 6. 4, enone :
and no preemption will be done. Non-preemptive
; priority eat
— 4
Example:
P2 P5 )
oe
—_—_—— "46 18 19
There are 7 processes P1, P2, P3, P4, P5, P6 and P7 given, Their respective priorities,
Gt Bi the |
Arrival Times and Burst times are given in the table below.
aN
Sixth Semester, Operating System
18-2018
RR (quantum = 1)
Turnaround time
FCFS RR SJF
Pl 10-0=10 19-0=19 19-0=19
P2 11 2 1
P3 13 7 4
se disk address of the blocks that contain the address of the blocks containing
: © €
the fle
- Advantages:
ges: | ag Q.8- (b) Define the = “Free Space Management” techniques. | (6.5)
* This is very flexible in terms of file size. File size can be increased easily since the
, } Ans The system keeps tracks of the free disk blocks for allocating g space
spa to files
system does not have to look for a contiguous chunk of memory.
; : : . . | when they are created. Also, to reuse the space released from deleting the files, free
¢ This method does not suffer from external fragmentation. This makes it relatively ce management becomes crucial. The system maintain ea :
s a free space list which keeps
better in terms of memory utilization. | | 2 age of the disk blocks that are not allocated to some file or directory. The free space
| tra
Disadvantages: list can be im plemented mainly as: |
-® Because the file blocks are distributed randomly on the disk, a large number of |
1. Bitmap or Bit ve ct or :
,
seeks are needed to access every block individually. This makes linked allocation slower. t Ve c tor is ser ies or col lection of bits where each bit cor res ponds to
‘t map or Bi
¢ It does not support random or direct access. We can not directly access the blocks ke tw o va lu es : 0 and 1: 0 in di ca te s that th e bl oc k is allocated
a di cisa
ee ° wie bit can ta
of a file. A block k of a file can be accessed by traversing k blocks sequentially (sequential
‘dicates a free block.
access ) from the starting block of the file via block pointers. nae of disk blocks on the disk in Fig.1 (where green blocks are
The given ; insta
in nce
¢ Pointers required in the linked allocation incur some extra overhead. a by a bitmap of 16 bits as:0000111000000110.
a te d) ca n be re pr esente
3. Indexed Allocation | alloc
fan ett ~
In this scheme, a special block known as the Index block contains the pointers to all he
_ the blocks occupied by a file. Each file has its own index block. The ith entry in the index : ss A ee
block contains the disk address of the ith file block. The directory entry contains the
address of the index block as shown in the image:
Advantages:
¢ This supports direct access to the blocks occupied by the file and therefore provides
fast access to the file blocks.
_ © It overcomes the problem of external fragmentation.
Disadvantages: | |
¢ The pointer overhead for indexed allocation is greater than linked allocation.
e For very small files, say files that expand only 2-3 blocks, the indexed allocation
would keep one entire block (index block) for the pointers which is inefficient in terms of
memory utilization. However, in linked allocation we lose the space of only 1 pointer
per
block. | | |
28-2018 .
> Sixth Semester, Operating System
Advantages:
* Simple to understand.
* Finding the fi a
rst fr ee block is efficient. It re 1. Address o t would cont
8 bits) in a bitma quires scanning the Words a py f firg¢ free d 2018-99
p for a non-zero word. (A 2. Anumber np isk block
0-valued word has all bits 0). sre
block is then found by scanning The fire
for the first 1 bit in the non-zero For example
word. in Pigure-1_ t
The block number can he first entry
be calculated as: of th «
(number of bits per word) “(number
of 0-values words) + offset of bit first
the non-zero word . bit
hy
l. For the Fig.1: We scan the bitmap sequentially
| for the first non-zero Word
| Mm can
the first group of 8 bits (00001110) constitute a non-zero word {BM paren veh Tenning MS-DOS or MicrosofWata ne For example
deny
0. After the non-0 word is found, we loo since all bits are p of ey ner ovaten, and hidder attributes
k for the first 1 bit. This is the 5th bit Of
the thy
madows have eapabilities
zero word. So, offset = 5. *Read-only - Allows a file to be read, but
"| nothin
changed = canbe written to the file or
Therefore, the first free block number = 8*0+
5 = 5. *Archive - Tells Windows Backup to backup the file
2. Linked List: In this approach, the free disk blocks are linked
together je a free
block contains a pointer to the next free block. The block number of the very first digi
block is stored at a separate location on disk and is also cached in memory.
eer,
for a file. The index contains pointers to the various blocks. To find an entry ;
the index is searched first and the pointer is then
used to access the file direct] fi
the desired entry. : Yeoh,
With a large file, the index itself may become too large to be libraries May interce de
kept in memo pina | for th
© user
solution is to create an index for the index file. The prim Positioning Includ
ary index file Would ¢ “Oh skipping forward or re
es adjusting
mr e
pointers to secondary index files that would point to the actual data items. Verse ag Well as € locat;
posit;
| For example, IBM’s indexed sequential access method (ISAM)
uses a SMall ma.
index that points to disk blocks of a secondary index. The secondary
index blocks a,
to the actual file blocks. The file is kept sorted on a defined key.
We first make abi a
search of the master index to find a particular item: It pro May cause the
vides the block number ae
secondary index. This block is read in. Binary search is used again to fing
the ‘fe :
“st and validating
containing the desired record. Finally, this block is searched sequentia <S to indicate
lly. In this ee
any record can be located from its key by at most direct access reads. °Y,
Q.9. (b) What is the logical file system and physic
al file system? (4) deletions)
Ans. | Additional information
Physical file Logical file oyna May be ne
e A password << Ssary, for €Xample
1. Occupies the portion of memory. 1. Does not occupy any memory e A declarat
ion that Oth
er Processes
It contains the original data. space. Does not contain any data, jt is using the obj haring). Th;
May access th
€ Sam:
loads itself at run time as per th Pe e,
In contrast oe n cethat no other
a aa aratio may depend
). This Process on th © object while the opeming
defined access path. , may ac e mitent of the other process.
other processes intent (exclusive use). “ess the object regardless of the
2. A physical file contains one record 2. A logical file can contain up to 32°
format. record formats.
3. Can exist even without LF 3. Can’t exist without PF ry
4. If there is a logical file for a PF, the 4. Ifthereisa logical file for a PF, the
PF can’t be deleted until and unless LF can be deleted without deleting
we delete the LF. the PF. | |
5. CRTPF command is used to create 5. CRTLF command is used to
such creat such object. object. 2. The process may be prohibited from acc
essing the object (it may be only
accessible by a group or specific user),
Q.9. (c) Explain the purpose of create,open and close in file system. (2.5)
Ans. A file system API is an application programming interface through which a 3. The file system may be unable to create or update structures required to
utility or user program requests services of a file system. An operating system may coordinate activities among users.
provide abstractions for accessing different file systems transparently. 4. Inthe case of a new (or replacement) object, there may not be sufficient capacity
Some file system APIs may also include interfaces for maintenance operations, such on the media.
S$ creating or initializing a file system, verifying the file system for integrity, and Depending on the programming language, additional specifications in the open may
defragmentation. ; establish the modules to handle these conditions. Some libraries specify a library module
Each operating system includes the APIs needed for the file systems it supports. - to the file system permitting analysis should the opening program be unable to perform
mpt
Microsof. Windows has file system APIs for NTFS and several FAT file systems. Linux any meaningful action as a result of a failure. For example, ifthe failureison the atte
ilure and
systems can include APIs for ext2, ext3, ReiserFS, and Btrfs to name a few. to open the necessary input file, the only action may be to report the fa
me la ng ua ge s si mp ly re tu rn a co de in di ca ti ng the ty pe of fai lure whic
Write, read and position: Writing user data to a file system is provided for the program. So
ec ke d by the pro gra m, whi ch dec ide s wha t to rep ort and if it can
use directly by the user program or the run-time library. The run-time library for always must be ch
continue. | : 7 em
some programming languages may provide type conversion, formatting and
ear ejecting removabl e media and
Fe updati
wigng library
sacl
blocking. Some file systems provide identification of records by key and may include Close may cause dismountinorg ejecting removadle
re-writing an existing record, This operation is sometimes called PUT or PUTX (if , sres to indicate that the object
is no longer
some
|
file systems provid
and file eysten Sa sarcaes object. Additionally,
the record exists) | specification to the close references
32-2018 Sixth Semester, Operating System
specifying a disposition of the object which may indicate
the object is to be dig
and no longer be part of the fi
le system. Sipamilalar to the open, tb “ard.
something may go it must be “XPecteq thatSq
wrong.
1. The specification of the object may be incorrect.
2. There may not be sufficient cap
acity on the media to iad uit dat
da
a be; ‘ |
or to output a structure indicating that the object wa ma ge s Duf fer e,
s succe
3. A device error may oc
cur on the media waere th
buffered data, the completion structur e as aie tho chan ing
e or updating meta data re |
example last access time). | JECt (fo.
4. A specification to release the object may be in
sll using the object.
co ns is tent with other PTOCE gga,
Considerations for handling a failure are similar to those of the open.
Types of real time syst
ems based on timing con
1. Har, d real time Sys straints:
tem: T nis type of system
can never miss its deadline
.
ed bra
:
crease
in
ine crease
a s.eTardiness means how late a ;
real time syy stem compmp
leteies tes iti s task with respect
Example: Flight controller system
.
2. Soft real time system: T
seinen = 94 wnt
ex section Total waiting tim
he
s
34 _ 6.8 unit
|
;
UMe=
* Ue
5
®
j
|
} while (TRUE); TA.T for B T coe 7 + 3 =
Rowe
10
"
="
stem
4—2019 Sixth Semester, Operating Sy Lp
Univers; a
Pi 042 2 2s ; Sity{B.Tech}-Aka
Shtal waiting shine = 84 ace page frame -, bat
No. of eT
Ans. 3 Ah"a as b 4,2.ce
Usdy _— .“
: 5A
So ATA. => a 10.8 Unit time. To be find — no. of page fault e
Q.2. (b) What is Virtual memory and how Overlay concept works, ©XDlain algo — optimal page replacement algo
short with example. , 2 1 2 4 i
Ans. Virtual memory is a memory management capability of an operating is, 4 4 4 = x x .
6 6| G {1 | 1} \ 1] \1]
(OS) that uses hardware and software to allow a computer to compensate for physi
PI (7 | , [S| |6| 6] le
memory shortages by temporarily transferring data from random access Memory (RA
) ‘ - 7| |7 | \7| t7| ra
to disk storage. Virtual address space is increased using active memory in RAY
inactive memory in hard disk drives (HDDs) to form contiguous addresses that hola 1 ra ry q X 3 ‘
both the application and its data. : ! 6 F | 1] {1
Virtual memory was developed at atime when physical memory becauge the 5 9 3 3 \4| \4\
installed RAM — was expensive. Computers have a finite amount of RAM, so memy 4 \ 2. 2
can run out, especially when multiple programs run a ee A system using So, total no. of page faults = 8. |
virtual memory uses a section of the hard drive to emula . With virtual memop, : ¢
a system can load larger programs or multiple programs running at the same tine A Eten fae ance apace of 4096 bytes. Main memory
allowing each one to operate as if it has infinite memory and without having to purchase ae .) what will beatna aka Meedlitictaaccaar cue partitioofn 16 byte each
more RAM. , Ce in the process? (c) How much internalGonuidccane. Pca ie
The main problem in Fixed partitioning is the size of a process has to be limited by ut the number of entries in general page table (e) How Pa @) rind
ere :¢ the page table is ses tearcecbedl cous Vieiaid many en Nees
the maximum size of the partition, which means a process can never be span over
another.In order to solve this problem, earlier people have used some solution whichis _ Ans. Logical address space = 4096 bytes
called as Overlays. | | = 22 bytes
| Then no. of bits is logical addr
The concept of overlays is that whenever a process is running it will not use the = 12 bits
complete program at the same time, it will use only some part of it.Then overlays concept
Main memory size = 512 bites = 2° bytes
says that whatever part you required, you load it an once the part is done, then you just
unload it, means just pull it back and get the new part you required and run it. Page size = 16 bytes
Formally, “The process of transferring a block of program code or other data into = 2* bytes
internal memory, replacing what is already stored”. | | Number of pages = Process size/Page size
Sometimes it happens that compare to the size of the biggest partition, the size of ye
the program will be even more, then, in that case, you should go with overlays. e = 28 = 256 page
So overlay is a technique to run a program that is bigger than the size of the physical Size of offset bits = 4 bits (because page size 2°)
memory by keeping only those instructions and data that are needed at any given ° = 256
no. of pages the process is divided
time.Divide the program into modules in such a way that not all modules need to be in No. of entries is page table =
the memory at the same time. | | No. Internal fragmentation
Q.3. (a) For a paged system, TLB hit ratio is 0.8. Let the RAM access time ‘t’ No. of pages = 2°
fr am es = 2° /2 * = 2 =3 2
be 100ns and the TLB access time ‘T’ be 50 ns. Calculate effective memory access No. of
time (with TLB). . of fr am es be co me no . of pa ges
In inverted page table, no
| (5)
Ans.
in in ve rt ed pa ge table =?
-. Entri e s
T(eff) = Hit ratio x (TLB access time + main memory access time) +
(1 — hit ratio) x (TLB access time (+) 2 x main memory time)
= 0.8 x (50 + 100) + (1 —.8) x (50 + 2 x 100)
= 0.8 x (150) + (.2) x (250) = 120.0 + 50.0 = 170.0 ns.
Q.3. (b) Calculate total number of page fault that will occur while processing
the page reference string given below:
4, 6, 7,1, 6, 7, 1, 2, 6, 2, 0, 3, 1, 4, 2 using Optimal page replacement policy;
when page frames are Three. (5)
END TERM EXAMINATION [JUNE 2019) | TYAB
Most OS also have an eta as .Tech|_Aka sh Books
SIXTH SEMESTER [B.TECH] mmands direct}
WO Canteoly toate; celatg
back door, wh;
if needed. In viens
2019-7
dita
OPERATING SYSTEMS [ETCS-304] peing accessed, an integer indicating a
to send
) System call ~%
Time :3 hrs. used for communicating oy coe
yoSAte
Note :- Attempt five questions in all including Q.No. 1. which MM. : 75 Caching involves keepin
is compulsory, Select
question from each unit : One data is normally stored.
Q.1. Answer the following short questions.
Q.1. (a) What does the CPU do when there are no programs to run
? (2.5)
Ans. If there are no tasks to run ona given CPU
in any of those classes gaya the
idle class, the CPU is regarded as idle. If the hardware doesn’
t make allowance for this
then the CPU will have to run useless instructions
until it is needed for real work, —
| Q.1. (b) Cana system detect that some of its processes are Star
ving? If yoy
answer “yes” explain how it can. If you answer “no”, explai
n how the System
deals with starvation problem?
(2.5)
Ans. Detection of starvation in effect requires future knowledge since no amount of
record-keeping statistics on processes can determine if it is making “progress”or not. directory sah This can be done, for example, by using the character
“” to indicate
the end of a subdirectory. Thus, for example, the
However, starvation can be prevented by “aging”a process. This means maintain name jim.java.F1 specifies that F1 is
ing a a file in subdirectory java which in turn is in the root
rollback count for each process, and including this as part of the cost factor in the selection directory jim. If file names were
limited to seven characters, then the above scheme could not
process for a victim for pre-emption/rollback. be utilized and thus, in
general, the answer is no. The next best approach in this situation would be to use a
Q.1. (c) In paging, why is it neccessary to add the page offset to the Starting
specific file as a symbol table (directory) to map arbitrarily long names (such as
address of the page frame to generate a physical address? (2.5) jim j ava.F 1) into shorter arbitrary names (such as XX00743), which are then used for
Ans. The offset is the distance (in bytes) relative to the start of the page. i.e., actual file access.
logical_address mod page_size. The bits for this portion of the logical address are not
Q.1. (g) How do placing index blocks near the data they reference, improve
translated (given power of two page size). The starting address of an n-bit page frame is (2.5)
a multiple of 2“n. Thus, the bit pattern of the frame’s starting address consists of the access time?
frame number followed by n 0’s. : Ans. Inodes allocated far from blocks — All inodes at beginning of disk, far from
|
Q.1. (d) What is hard page fault and soft page fault? data — Traversing file name paths, manipulatng files, directories requires going back
(2.5)
and forth from in nodes to data blocks.
Ans. Hard page faults occur when the page is not located in physical memory ora for the same file
memory-mapped file created by the process ... On the other hand, a soft page fault occur Data blocks allocated randomly in aging file systems — Blocks
s when FS is new As FS “ag es” and fill s, nee d to allocate into
when the page is resident elsewhere in memory allocated sequentially entially
eted — Problem: eet —s
blocks freed up when other files are del
Q.1. (e) Where are the following tasks implemented, in the logical I/O
layer, blo cks for ne w fil es be co me sca tte red 7 st = sang
the device driver, or both ? randomly placed — So,
, €2.5) in g of dis k, far fro m dat a. h a h aaa
All inodes at begi nn
(i) Checking access permissions ng back and fo
es, dir ect ori es req uir es goi
manipulating fil d a m e m o ry acce=ss
(ii) Scheduling the I/O operations
fault servic e i em . 25 ms an
Q.1. (h ) If th e av er ag e pa se
(iii) Checking if the requested information is in the cach th e ef fe ct iv e access 0
e Ca lc ul at e
time of 100ns. + memory access time.
Ans, User application access to a wide variety
of different devices is accomplished - a s fault service time
Ans tive access time = Page
through layering, and through encapsulating all of the device-specific code into
device
drivers, while application layers are presented with a common interface for all ( or ad lo ck to © ecu re? (2.5 )
45 for de
at rurn necessaryexco nd it+4:ions
least large general categories of.) devices. Q.1. (i) What are the fo amination 2018. (Page No. 20-2018)
Most devices can be characterized as either block I/O, character I/O, mem torQ. No. 6(a) End Term
Ans. Refe (2.5)
ory mapped
c a u s e s o f T h r a s h ing?
file access, or network sockets. A few devices are special, such as time-of-day
clock and . (j ) W h a t a r e t he
the system timer.
Q.1
82019 Sixth Semester, Operating System
UNIT -I
Q.2. (a) Compare and Constrast Network, Parallel and distributeg ope 2019-9
Ta ;
sysbems.,
Paging is am “ntation LE
Advantages of Variable Partitio use in primary dram a data to, ' ‘and reading
ning ~ management
’
for
0 0
a computer’s
it & ad=
O8 (ove Main Memory, hig denen storage for
1. No Internal Fragmentatio
n: In vari In a memory management syster,rat ting system), 5 & tole
role; in memory _
is allocated strictly data from secondary stor
. age inb that takes ady
antage :
physical region of memory jag Called pages, all ane ung, the OS reads
NG; @ Single page 82 is; called
COMprise & frame. When
storage. This approach offers an shusiees ohysically continous paging is
until the memory is not empty. pecause it facilitates more effic BE over earlier
| 3. — Limitation on the size of the
process: In Fixed partitioning the pr
with the size greater than the size of the largest par ocess
tition could not be lowed and process Dut still suffer from internal
can not be divided as it is invalid in contiguous all fragmentation.
ocation technique. Here, In variable ° Paging is simple to implem
partitioning, the process size can’t be restricted sin sechinidle ent and assumed as
ce the partition size is decided 7
an efficient memory management
according to the process size. | * Due to equal size of the pages and
frames, swapping becomes very easy
Disadvantages of Variable Partitioning - e Page table requires extra memor |
be good fora system . having
1. Difficult Implementation: Implementing variable Partitioning is difficult as small RAM. SRA THEMOTY space, 80 may not
compared to Fixed Partitioning as it involves allocation of memory during run-time rather pageowin
Q.3. (b) Consider the foll g
reference string: (8)
than during system configure. | | 7, 2, 3, 1, 2, 5, 3, 4, 6, 1, T,1, 0, 5, 4, 6, 2,3, 0,1.
2. External Fragmentation: There will be external fragmentation inspite of Assuming demand paging with three frames, how many page faults would
absence of internal fragmentation. occur for the following replacement algorithms?
For example, suppose in above example- process P1(2MB) and process P3(1MB) (i) LRU replacement :
_ completed their execution. Hence two spaces are left i.e. 2MB and 1MB. Let’s suppose (ii) MFU replacement
srocess P5 of size 3MB comes. The empty space in memory cannot be allocated as no (iii) Optimal replacement
anning is allowed in contiguous allocation. The rule says that process must be 2, 3, 1, 25 ,3 ,4 ,6 ,7 ,7 , 1, 05 , 4, 82 3,051
Ans. String 7,
mtiguously present in main memory to get executed. Hence it results in External
No. of frames - 3
'Fragmentation. |
(i) LRU replacement
The buddy system is a memory allocation and management algorithm that
manages memory in power of two increments. Assume the memory size is 2U, suppose I mi
X
Xx
Tpol als
a size of S is required.
1 \7
¢ If 2U-1<§<=2U: Allocate the whole block 2
« Else: Recursively divide the block equally and test the condition at each time,
.
|8
when it satisfies, allocate the block and get out the loop.
' System also keep the record of all the unallocated blocks each and can merge these
different size blocks to make one big chunk,
: e
a
Advantage -
* Easy to implement a buddy system
* Allocates block of correct size
,sv
|
Sixth Semester, Operating System
; , ,
3 1 1 1 1 1 1 t
jnitially set to 0. asks, Tl and T2 share the integer variables X, Y
x x 6 7 8 x 9 10 Xe ae
0 0 0 0 0 Task T1 execut
7 7 0 0 0 ! ,
X: = 0: es: Task T2 2)
7 Fee ;
Bh (Bde FO} eB] [Bt 3] Shiv abate 31 tae
i 1 i 5 4 403|4 4 4). [ap If X>0 then
white Y¥<2d
X; aX + Is > ¥-1- z
11 + III = 14 Page fault |
=> Y¥:=2;
’ PS
Y=1;
7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0, 1 What are the possible values
) of< X and Y wh termina
(iii) Optimal Page Replacement Ans. Final value for
Men cee ny
x ae a, a
x | x x 1 X 2 xX 3 4 5
7 7 7 1 1 1 1 1 ry | 1 y: =
Q.4. (c) What resources are used
Bia Olas eae es She ee Bl Becks those when a process is created ?
when a thread is created? How do
they from
B( Sih. (Sl = (31) As) als el ne Ans. When a
) (2.5)
thread is created the threads does not
x x 6 x 7 8 9 10 x x require any new resources to
execute the thread shares the resources like
1 I 1 1 1 1 1 1 1 1 memory of the process to which they belong
to. The benefit of code sharing is that it allows an appl
5 5 5 5 4 6 2 8 iS 3 ication to have several different
threads of activity all within the same address space. Wherea if
7 7 0 0 0 0} 0 s a new process creation
0 0 0 is very heavyweight because it always requires new addres spa
s ce to be created and
even if they share the memory then the inter process communication is expensive when
> 10+ UI = 18 Page fault
compared to the communication between the threads. >
| P, | Py Ps Ps P3
queue 0 4 3 -
ded wait ing: Ther e must exist a bound on the number of times that other 7 412 20
3. Boun ion s S after a process has made qa request Priority
- the ir
ir cricriti
tic al sec tio 1
processe 5 are allowed
to ente! the =
request is granted
ter its cri tic al sec tio n and before that
to enter
The wait is the time from when a process makes a request to enter its Critica] | P, | Py | Pa Pe Ps
ih
r e q u e s t is g r a n ted Pee sa te 20 LJ
section until that RR (quantum
= 2) |
In practic
c e s s e n t e r s its cr it ic al se ct io n, it d o e s no t ge t a n o ther turn
e, once a pro a turn (managed as a queue).
until a waiting process gets L
2
1 L P2
e re quir em en ts fo r cr it ic al sect ion problem Ps | P, | Ps | P3 P, | Fa} Pal Ps § Fs -
The th re 3 5 7 3 11 "15
- Suppose that Pi is in its critical section, and Pk(k!=i) has already chosen its 18 20
(ii) FCES
number[k], there are two cases:
1. Pk has already chosen its number when Pi does the last test before entering its TA = 2+3+11+15 +20
critical section. 5
In this case, if (number({iJ, 1) < (number[k],k) does not hold, since they cannot be
equal, so (number|i],i) > (aumber[k],k). Suppose this is true, then Pi cannot get into the
_ 5h 8 = 10.2
cirtical section before Pk does, and Pi will looping at the last while statement until the
condition does not hold, which is modifiedby Pk when it exits from its critical section, SIF _-1+347+12+20 .
Note that if Pk get a new number again, it must be larger than that of Pi’s. 5
2. Pk did not chose its number when Pi does the last test before entering its critica]
section. | awa
5
In this case, since Pk has chosen its number when P’ is in its critical section, Pk
must chose its number later than Pi. According to the algorithm, Pk can only get a bigger
ee 1+3+7+12+20
number than Pi, so (number[i],i) < number([k],k) holds. Priority = 5
Q.5. (b) Consider the following set of processes, with the length of the CPU
burst given in milliseconds: | (6.5)
= oF5 — acO.U.
Process | ‘Burst Time Priority
P Qi? | 2
42
2+3+53+20+
P, 1 a en = el
PR; 8 | 4
P, | 4 2 Rg
r 5 3 | 5
; le |
The process are assumed to have arrived in the order P,, P,, P,, P,, P; all at (iii) FCS ions
time 0. Answer the following questions using the following scheduling P,=90 P=}
algorithms: FCFS, SJE, Priority and RR(quantum=2)
P,=2 P,=0
({) Draw Gantt chart that illustrates the execution of these processes.
P,=3 Re
(ii) What is the turnaround time of each process for each of the scheduling
algorithm ? Ae | P,=il ¥,=0
(iii) What is the waiting time of each process for each of the scheduling P.=15 s
algorithm ? | : a a Priority 5 ‘
Ans. (i) FCFS pat °
P,=0
P,=2
3
re P,=49
Pp, = 12
, Op er at in g System
Semester
16-2019 Sixth p, = 16 ier |
IP. University-[B.Tech]|-Akash Books 2019-17
P,=3 P,=37 Q.6. (b) Why will da
P.=7 5 7
opeating systems than eadlock probably
it is today? Just Sty beseed
a moa iti problem in future
UNIT - Hil ae Ans. Sure, Deadlock probably be more critical
‘ ing current resource.
Q.6. (a) Consider a system with the followine © a allocatig,
state: P,, Py» Py Ps and three resource types: 4 p (6)
There are five processes: Pos : wienum: 2 Z Ang
C. For each process, the current allocation nee ein allocati,
mat ric es. The curren t available resource n
are given by Allocation and MAX are algorithms will be needed.
given by the Available vector. . - : pis
Answer the following questions using the Banker’s algorithm: s ~vasaieah dea a aaa Postponement? How does Indefinite
peceeneas ‘Aligoation z . — ; 2. ae Pos rtorm deadlock? How does Indefi
to deadlock? efinite ni Postponement similar
A B 5 ; ‘ 5 ; C Discuss the consequences of IP in the following types of Syste
Po 1 1
ms: (4.5)
2 ; - 5 0 (i) Batch processing
P. 2 1 | 2 , ; 5 (ii) Time sharing
P. 4 0 ; : : ; (iii) Real time
P4 0 2 : eS : onement may
Ans. Indefinite postp occur because of resource scheduling policies.
P,. 1 1 When resources are scheduled on a priority basis, it is possible for a given process
to
wait for a resource indefinitely as processes with higher priorities continue arriving. In
(i) What is the content of the Need matrix?
some systems, indefinite postponement is prevented by allowing a process’s priority to
(ii) Determine if this state is “safe” using Safety algorithm.
increase as it waits for a resource. This is called aging.
(iii) If a request from process P, arrives for (7,2,3) can the request be granted
immediately? In any system that keeps processes waiting while it makes resource allocation and
|
Ans. (i) Need matrix = Max , Allocation. Coe
is iti
ee ee ee a 1 Eenntodelay instefiniknly the echetolingel apracies
while other processes receive the system’s attention. This situation, called as indefinite
Process A B | Cc postponement or indefinite blocking or starvation.
P 3 2 1 ae Basis for Deadlock Starvation
P, 1 1 0 | YS Comparision ,
P; 5 0 l Basic Deadlock is where Starvation is where low priority
P, 7 3 3 : no process proceeds, and processes get blocked, and high
Pe. 10 1 1 get blocked. priority process proceeds.
; 7 : Arising condition | The occurrence of Mutual Enforcement of priorities,
(ii) P, cannot:run at first because need is more than available so— exclusion, Hold and wait, uncontrolled resource
first > ‘P,’, (1,1,0) < (2,1,0) available No preemption and management.
then available will be (4,2,2) Circular wait
Now > ‘P,’run simultaneously.
available 5,3,4 Other name Circular wait. Lifelock..
Now > P,’run Resources In deadlocked, requested In starvation, the requested
available 9,3,5 resources are blocked resources are continuously used
Now > P,’run are blocked by the other by high priority processes.
available 9,5,5 PRoceseds: es oe
oe is * 2 s cannot execute as demand/need is more than available. So system is not vrereutaa oe TA aad wail
0 | 6 33 | 74 75 99
4? oe a a i
52
—@
99
Total head movement
= (63~ 72) + (72-74) + (7475) (75— 92) + (52-47) 72 74 75 99
+ (47— 33) + (83-8) + (8-99)
—.——_.—_______,
(3
(ii) If the disk rotates at 3600 rpm, what is the effective data
transfer rate;
bytes/sec?
:;
Ans. Writable/readable area = 16—6 = 10 cm. physical block.
inner track space = 0.2 mm (ii) For indexed allocation direct access
. is also possible, but fir
100 indexing of that block through index block. So to ‘2? ur iirst we have to know
so total no. of tracks = om 500 tracks block access would be required
.
Q.8. (b) Discuss; various techni
ques for imi plementing File Access
(1) Sector size in bytes = 4 byte. Which techniqu e is appropriate for most of th Control.
e Systems? 4 a
(ii). Data transfer rate = no. of heads x capacity Ans. Access control is a security technique
of one track x no. of rotations/second. that can be used to regulate who or what
= 8 x 96 x 60 = 46,080 bytes/second. can view or use resources in a computing environment.
| |
Q.7. (c) What do you mean by Sector queuing? Describe There are two main types of access control: physical
SPTF algorithm, and logical. Physical access
control limits access to campuses, buildings, rooms and physical IT assets. Logi
cal
(3.5) access limits connections to computer networks, system files and data.
Ans. Sector queuing is an algorithm for scheduling fixed-head
devices. It is based The four main categories of access control are:
on the division of each track into fixed number of blocks called sectors. The disk a
in each request specifies the track and sector. Since seek time is zero for
ddress ¢ Mandatory access control —
fixed-head devices,
the main service time is latency time. For FCFS scheduling, assumi e Discretionary access control
ng that requ ests are
uniform distributed over sectors, the expected latency is one- e Role-based access control
half of a revolution.
e Rule-based access control
UNIT
- IV
' Access: control systems perform authorization identification, authentication,
Q.8. (a) Consider a file system on a disk that has both logical and
physical access approval, and accountability of entities through login credentials
sizes of 512 bytes. Assume that the information about each file is
already in including passwords, personal identification numbers (PINs), biometric scans, and
memory. For each of the three allocation strategies (contiguous, linked, and physical or electronic keys.
indexed), answer the following questions: (2.5)
(6) Q.8. (c) How operating system manages mounted file systems?
(i) How the logical to physical address mapping accomplished in this syst
em? Ans. Unix-like systems assign a device name to each device, but this is not how the
(For indexed allocation, also assume that a file is always less than 512 block ee
s files on that device are accessed. Instead, to gain access to files on another ao
long). Assume a pointer size of 1 byte. ae . . S
: operating system must first be informed where in the directory tree those
to sone ie
(ii) If we are currently at logical block 10 and want to access logical block 4, appear. This process is called mounting a file system. For example,
the file noe ae
how many physical blocks must be read from the disk? on a CD-ROM, one must tell the operating system “Take
. The ses = . Se
Ans. Let Z be the starting file address (block no.). ROM and make it appear under such-and-such ama
or ae cas
For contiguous allocation operating system is called the mount point — it sae
>
(1) Divide the logical address by 512 with X and Y the resulting quotient and remainder Se for removable media
neds is intendveed 9spe aN i =
respectively. Add X to Z to obtain the physcial block number, then Y is the displacement od See USB seas or floppy disks. It may be empty, or 1t may contal
into that block. 7 to ri es for mo un ti ng in di vi du al eee
subdir ec unting of file
) ma y au th or iz e th e mo
(11) In contiguous we can access any block directly so we can directly access block 4, ra ll y, on ly th e ad mi ni st ra to r (i.e. root user
Gene
the block must be read is ‘1’, |
systems.
Fr
22+~2019 Sixth Semester, Operating System
Just like a file needs to be opened, a file system needs to be mounted. Os n.
LP. University_(B ‘Tec
know — The location of the device (partition) to be mounted — The location h|~Akash Books
in thee to Once that test passes, it wi 2019-23
file structure where the file system is to be attached. OS does, — Verify ll check the file contents fo
that th “Urreny text scripts — or an ELF r a #! (Shebang) header — fo
has a valid file system — Add new file system to the mount point header — for the most r |
(/medi aly) e deviog common binary executable fo
rmat. It
Q.9. (a) Explain various file alloca \ 1) \
tion methods with their Pros ang
~
Ons,
Ans. Refer to Q.No. 8(a), End Term Examination 2018. (Page No.
25-2018) (6.5)
Q.9. (b) How does support for havi
ng file with mu]
the delection operation on a file system? tiple names ¢ commands to be issued to the operating sy
stem (similar to a batch file). With
°MPlicate introduction of CP/M the
Ans, (a microcomputer operating system), the
(3) type of files commonly me
associated with COM extension changed to
| Physical file Logical file >= later
that of executable files. This convention was
carried over to DOS. Even when complement
| ed by the more general EXE file
1. | Occupies the portion of memory. > : format for executables, the compact COM files rema
1./ Does ined viable and frequently used
| It contains the original data.
not occu a i) Se ae under DOS.
are, memory
A file system API is an application programming interface through which a utility
or user program requests services of a file system. An operating system may provide
2.|A physical file contains
one record abstractions for accessing different file systems transparently.
> 2. A logical file can
format. contain up to 32 Some file system APIs may also include interfaces for maintenance operations, such
record formats.
3.|Can exist even without
LF as creating or initializing a file system, verifying the file system for integrity,
: oe Can’t exist without PF
4. | If there is a logical file for and defragmentation. |
a PF the 4. If there isa logical
PF can’t be deleted until file tor a PF the Each operating system includes the APIs needed for the file erates i
and unless LF can be deleted wit
we delete the LF hout deleting supports. Microsoft Windows has file system APIs for NTFS and several FAT Sle
| the PF
5.| CRTPF command is used to create systems. Linuxsystems can include APIs for ext2, ext3, Reiser'S, and Btrfs toname a few.
5. | CRTLF command is used to |
such creat such object. Write, read and position
object.
Writing user data to a file system is provided for use directly by the user program
Different operating system keep tr >
ack of different file attributes includ
ing: r the run-time library. The run-time library for some eats ng os es
= |
| blocking. 8Some file ‘sy systems provi
3 vide type conversion, forma tting and
aan of records by key and may include re-writing an ore record
hed ena:
operation is sometimes called PUT or PUTX (if the at exists
aae aglow
Identifier - for example inode number Reading user data, sometimes called GET, may include
d file syst em, a speci fic key. As wi Wri -
_ Type - Text, executable, other binary reverse) or in the case of a keye
etc.
And many more like location, size, pro am.
tec tion, time and date etc. libraries may intercede fur Cleves: Bae o _ pa
Thisremaytiginclude
loc ati on of the pa s rec
System which did not originally have
multiple user file access permissions mu Positioning includes adjusting the
now be retrofitted if they are to share files st fo rw ar d or rev ers e as wel l as pos iti oni ng to the beginnin
ina network. Access to a file requires access skipping
to all the files along its path as well.- Open and close
In a cyclic directory structure user ma . 1: tly invoked upon the issuance
different access to the same file accessed y have : ‘ci ted or implicitly in pon bl
through different paths. Sometimes just The | open API Ari may be explicitly requesect. It may cause the m ounting a of reme ovable
knowledge of the existance of a file a certai the
ess on an obj
n name is a security concern. The file which of the first operation by a proc k . apand validating the met
is saved with multiple names arise a pr a co nn ec ti on to i ai
the gr id
hos t an 5 ind ica te tha t the
oblem with storage why some files are ) media, esta bl is hi ng obj ect is
replicated means contents with different e ob je ct . It updates sy
names. There is no problem in deletion of acce ss ib il it y of th
such type of files. Although there would be a pr
oblem if different files saved with single in use. t e m ob je ct include:
name and different extension. t oa fi le s y s
} u i r e m e n t s fo r r e q uesting access
Usual req i
ct o ry , m e d i a an d lo ca tion)
Q.9. (c) Why DOS and UNIX operating system
s recognize only executable w h i c h is to be ac ce ss e d (file, dire
1. The object th e op en (r ea ds , up dates,
files? | op er at ions to b be performe d afte r
(3) n t e n d e d ty pe of
Ans. There is the executable flag (Unix systems wil 2. The i
l refuse trying to interpret a file deletions) mation may be necessary, for example
as executable if the execute permission is not gra
nted; it applies even to root which "Additional info
ignores only read and write permissions, and treats any
of the execute bits as its own). * a password
_
;
zy
——————————
ti‘ S.w*;*;:S*Y ~~
24-2019
Sixth Semester, Operating System
proces* s8 jcdecilhaerat "5 other processes may access the same obj
ect whi]
In contrast 1€ Object (shariningg)). ThisThi may depend on the ii ntent of the “¢ ot
thh e *Pening
other ast , a dec lar
~‘aatration that no other process may access the
er processes intent (exclusive use).
ohi- €T prog
‘ object Pegardlag, itis, Q
These are r
equested via 4 progra
coordination a mming language library
ile idee: ©ng modu which m
in th
mm
quest to the
It mus
tbe ©€xpected that
7
something may go
wrong 8 Pp
a. The ob} . cessing of the Ope
Ject or intent may be i 1 7
y be improperly specified (the name
unac ceptable character or the intent . p nh.