Operating System
Operating System
ntutpter 1 j Overview of Operating System 1-1 to 1-30 (June 1 5 , Nov. 1 5 ) ........ ........ u .. b+n... a......... 1—16
Operating System Design and implementation, OS structure. 1.13 System Calls (June 15, Nov. 15, May 1 6 ) . „............... v i e
Virtual machines, OS debugging and generation, System boot. z - Syllabus Topic : Types of System Calls ..................... 1-19
✓ Syllabus Topic : Introduction .............. .............................. 1 -1 1 .1 3 . 1 Types of System Calls (Juno 15, Nov. 15) ....... ......... 1 - 1 9
1 .1 Introduction to Operating System 1 . 1 3.2 Some Examples of System Calls — ............ 1-20
i (Dec. 14, June 15, Nov. 15) .............................................. 1-1
z Syllabus Topic : System Programs ............. .................. 1-20
Z Syllabus Topic : Operating System Structure .............. 1-1
1.14 System Programs ......................„........................................ 1 -20
12 Operating System Structure ............ ................................. . 1 -1
1 . 1 4. 1 Comparison between System Program and
1 2. 1 Monolithic Systems ....................................... 1-2
Application Program .....„.............................................. „...1-21
X22 Layered Systems. ................................................................, 1-2 z Syllabus Topic : Operating System Design
1.2.4 Monolithic Kernel vs. Microkernel 1.15 Operating System Design and Implementation 1 -22
Scanned by CamScanner
2.14.1 The torxu ano exec() System
2.14.2 Cancellation
2.8,1 Scheduling Queues and Schedulers ............................ 2-6 2.16.2(F) Multilevel Feedback-Queue Scheduling — -
Scanned by CamScanner
Operating tem (MU ■ Sem 4 -JT) 3 Table of Contents
rhnpter 3 : Process Coordination 3-1 to 3-27 3.13 Deadlock Charactenzation ............................................ 3-15
3.13.1 Conditions (June 15, Nov. 15, May 16, Dk. 16)....... 3-15
SylLatrns : Synchronization : The critical Section Problem,
Peterson's Solulion* synchronization Hardware and semaphores. 3.13 .2 Resource Allocation Graphs (Dac. 16) ........................ 3-15
Classic problems of synchronization, monitors, Atomic z Syllabus Topic : Deadlock Prevention ....................... 3-16
transactions; 3.14 Deadlock Prevention (June 15, Nov. 15} ....... *....... ....3-16
Deadlocks System Model, Deadlock Characterization, Methods z Syllabus Topic : Deadlock Avoidance ....................... 3-17
for Handling Deadlocks, Deadlock Prevention, Deadlock 3.15 Deadlock Avoidance (June 15, Nov, 15} .................... 3-17
Avoidance , Deadlock Detection, Recovery from Deadlock. 3 1 5. 1 Deadlock Avoidance Algorithms
/ Syllabus Topic : Synchronization ................................. 3-1 (May 16, Dec. 16) .......................................................... 3-1B
3.1 Background (May 16)....................................................... 3-1 3.15.1(A) Resource-Allocation Graph Algorithm ......................... 3-19
3.2 interprocess Communication (May 16} ......................... 3-2 3.151(B) Banker's Algorithm (Dec* 16}......................................... 3-19
33 Race Condition ................................. *............. 3-3 3.15.1(C) Resource- Request Algorithm......................................... 3-19
z Syllabus Topic : The Critical Section Problem ............ 3-4 3.15.1(D) Safety Algorithm......................................... *.................... 3-20
3.4 The Critical Section Problem (Dec. 14, June 15) ........ 3-4
3.16 Solved Problems . ............ 3-21
3.5 Mutual Exclusion (June 15, Nov. 15, May 16) ............. 3-5 z Syllabus Topic : Deadlock Detection .........*...... *....... 3-23
z Syllabus Topic : Patersons Solution............................ 3-5 3.1 7 Deadlock Detection (June 15} ................ 3-23
3.6 Peterson’s Solution................ *..... *............. 3-5 J Syllabus Topic : Recovery from Deadlock ................. 3-25
Z Syllabus Topic ; Synchronization Hardware ................ 3-6 3.1B Deadlock Recovery............... 3-25
3.7 Synchronization Hardware ............................................... 3-6 3.13.1 Process Termination (Kill a process)-.......* ................. 3-25
J Syllabus Topic : Semaphores ....................................... 3-7
3.16.2 Resource Preemption . ............................... 3-25
3.8 Semaphores ..................... - ..................... 3 ’ 7
3. 19 Exam Pack (University and Review Questions) ....... 3-26
Z Syllabus Topic : Classic Problems
of Synchronization............................................................. 3-B Module IV
3.9 Classic Problems of Synchronization ............................. 3-0
Chapter 4 : Memory Management 4-1 to 4-35
3.9.1 Producer Consumer Problem (Dec, 16} ........................ 3-8
Syllabus : Memory Management strategies : Background,
3.9.2 Producer Consumer Problem
Using Semaphore (June 1 5 ) . *.............. *....................... - 3-8 Swapping, Contiguous Memory Allocation, Paging , Structure of
the Page Table. Segmentation; Virtual Memory Management:
3.9.3 Readers/Wrtters Problem ............................... *................. 3 9
311 Atomic Transactions .............................................. *........ 3-12 4. 1 Memory Management Strategies...... *..... *...................... 4-1
3,11*1 System Model of Atomic Transactions ......................... 3-1 2 4.1.1 Monoprogramming ................................. *****..................... 4-1
3-11,3 Checkpoints.................... ................. ........ .............- 3-13 4. 1.3 Dynamic Loading .............. * ............................. *....... 4-2
3.11-4 Concurrent Atomic Transactions ....... ............ 3*13 4.1.4 Overlays ..............................................................................
3.11.4(A) Serializability...... ....... .......... .......................... 3* 1 3 Relocation ................................ 4-3
3 13
3.11.4(B) Locking Protocol................. .......... *....................... — ' Logical and Physical Address Space ........................ *..... 4-3
1 4
3.1 1.4(C) Time stamp-Based Protocols . ..... *......... * Syllabus Topic : Swapping .............................*............. 4-3
4-3
z
Syllabus Topic : Deadlocks ................................... -..... 3
'14 Swapping ..................... .......
a ....
* .
— ..
3.12 Deadlocks (Jun* 15, Not* 15* May 16, □«. 16) 3-1 4 Syllabus Topic : Contiguous Memory Allocation ...... 4-4
z
Syllabu ■ Topic ; System Model ................................... 3“ 14
Contiguous Memory Allocation .......... ...... ............ i" 4 " 4 .
Scanned by CamScanner
4
Operating System (MU • Sem 4 - IT)
4.9.5
4,2.1 Multiprogramming with Fixed and Counting-Based P age R
4.6
°ther Considerations
Segmentatjon p
Prepaging Sy
Sy
" » Topic ........... .......... Pre
<17,2 p
Virtual Memory Management a9 *""*''' *' S age Size
Scanned by CamScanner
Table of Contents
..... 5-25
...... 5-1 5.2.5 Free Space Management ............♦ *
Syllabus Topic : Ale System - File Concept. ..... 5-25
........ 5-1 5.2.5(A) Bit Map or Bit Vector ...... -
5.1 File System ..... 5-26
........ 5-1 5.2.5(B) Linked Ust of Disk Blocks . ...............
Pile Concept 5-26
........ 5-1 5.2.5(C) Grouping .......... ..............................
5.1.2 File Attributes ...................... — ..... 5-26
........ 5-2 5.2.5(D) Counting - *
Fife Operations * 5-26
5.1.3
........ 5-3 ✓ Syllabus Topic : Efficiency and Performance
Fite Naming ................................... - +;... 5-26
........ 5-4 52.6 Efficiency and Performance.... ..............
5.15 File Types ..... 5-26
........ 5-5 5.2.6(A) Efficiency -.............................—
51.6 Fite Structure ....................-.................. ..... 5-27
........ 5-6 5.2.6(B) Performance ............................. —
..... 5-28
........ 5-6 Syllabus Topic : Recovery........................ -
Access Methods (June 15) .....5-2S
........ 5-7 5.2.7 Recovery
Syllabus Topic : Directory Structures ..... 5-29
5.2.7(A) Consistency Checking *..................
........ 5-7
Directory Structures . ..... .....5-29
5.1.6 52.7(B) Backup and Restore ................... —................
........ 5-7
5 1 8(A) ' Single-Level Directory Systems ..... 5-29
5.2.7(C) Log-Structured File Systems * «-
........ 5-7
Two-level Directory Systems.... 5-30
5.1.6(B)
........ 5-8 ✓
5.18(C) Hierarchical Directory Systems 5-30
........ 5-9 5.2.8 NFS
Path Names ............ 5-30
5.1.9 NFS Architecture ..... ++.................... *.......-....... -
........ 5-9 5.2.8(A)
Directory Operations . .......... 5-30
5,1.10 NFS Protocols... ....................... *
...... 5-10 5.2.0(B)
„ 5-31
.... 5-10 5.26(C) NFS Implementation.,.. *......................
FileSystem Mounting ....... -......
...... 5-1 1 ✓ Syllabus Topic : Secondary Storage Structure 5-31
5.1.12 Working of Files , ....... Secondary Storage Structure... +,-....+*-—
... 5-12 5.3
Syllabus Topic : File Sharing
....... 5-12 ✓ Syllabus Topic : Overview of Mass-Storage
5-31
5.1.13 File Sharing . * Structure . ............*.......... - ..... .................
....... 5-12 .......5-31
5.1.13(A) Multiple Users 5.3.1 Overview of Mass-Storage Structure... ...........
..... „ 5-13 ...... 5-31
5.1.13(B) Remote File System 5.3.1(A) Magnetic Disks ..... ............-...... —.....................
....... 5-14 5-32
5.3.1(B) Magnetic Tapes ......... ...............*............
...... 5-14 ...... 5-32
✓ Sy llabus Topic ; Protection -.......... y' Syllabus Topic ; Disk Structure..... .....
...... 5-14 5-32
5.1.14 Protection * - * 5.3.2 Disk Structure ..........* - ....... *
...... 5-14 5-33
5.1.14(A) Type of Accesses ........................ - ✓ Syllabus Topic : Disk Attachment..
...... 5-15 .5-33
5. 1, 1 4(B) Protection Domains *.................' 5.33 Disk Attachment ............... ........—...........
...... 5-15 5-33
5.1.14(C) Access Control 5.3.3(A) Host- Attached Storage...... * ’
...... 5-16 ......5-33
Syllabus Topic : File System implementation Network- Attached Storage (NAS)
5.3.3(B) ..... 5-33
...... 5-16
52 File System implementation -- Storage-Area Network (SAN) ...........-..............
5.3.3(C) 5-34
...... 5-17
52.1 Fite System Structure ' *-
...... 5-17 5-34
15
Syllabus Topic : Implementing File System ... 5.3.4 Disk Scheduling (Nov* )
...... 5-17 ..34
5.22 Implementing Fite System... * - 5.34(A)
...... 5-18
5.2.2(A) File System Layout.. 5.3.4(B) „„ 5-34
...... 5-18
5.22(B) Virtual File System Algorithm (Dec. 16) .............-- ................
; 5-35
...5-19
5.3.4(C) SCAN Scheduling Algorithm (Dec. 16).....
...... 5-36
... 5-19 C-SCAN Scheduling Algorithm (Dec. 1 6 ) .
52.3 Directory Implementation ................ 5.3.4(D) ...... ,+.5-36
...... 5-19
5.2.3(A) Linear List 5.3.4(E) LOOK Scheduling Algorithm (Dec. 16)
5-37
...... 5-21 Examples on Disk Scheduling Algorithms
52.3(B) Hash Table 5.3.5 ......... 5-42
...... 5-21 syllabus Topic ! Disk Management ........
Syllabus Topic : Allocation Methods 5-42
...... 5-21
52.4 Allocation Methods (Dec. 14, May 1®) 5.3.6 Disk Management....... ........... *...........
5-42
...... 5-21
5.2.4(A) Contiguous Allocation,....,. - * 5.36(A) Disk Formatting - 5-43
...... 5-22
52.4(0) Linked List Allocation - 5.36(B) Boot Block. ........... -......... . ...... :........ *........
...... 5-23 Sad Blocks
52.4(C) Linked Ust Allocation using a Table in Memory , 5.3.6(C) .5-43
...... 5-23
Syllabus Topic ; RAID Structure
52.4(0) Indexed Allocation ♦■- * * .5-43
...... 5-25
5.2.4(E) I-nodes,., 5.3*7 RAID Structure *
...... 5-25 |
Syllabus Topic £ Free Space Management.....
Scanned by CamScanner
Module VI
5-43
syl
5.3.6 St ' X'Xstorag® - * s sX bu
”
Distribu,ed rae sys,em:
5.3.9(A) Te
«-s» ;..... . ..... ... Licata Distributed Synchronization :
K P _ _i 1 anrl Uparfloclc nanrlltriA
5.39(B)
o psra iing-sys ' en ’ Suppo
■■"■■■■" .......... — ------------------ — "&■
..... 5'49 Concui
pedomance ™
5.3.9(C) ' j Tropte: Distributed Opeptfngs .92
(
Syllabus Topic :Swap-w .... 5-49
p-SpaceMaW !m9nl
................... ....... 5-49 Distributed Systems.................... ........... — 1 A3 (
swa
5.3.10 6.1
5.3.10(A) Swat>Spa« ... ....................... ......... ....... 5-50 Definition ..................*..............................— -9.4 C
5.42(E) Direct Memory Access (DMA) ................... ........ 5-53 6.2.1(B) Remote File Transfer .......... . ........... -....... -12.1(C) To*
Syllabus Topic : Application I/O Interlace ..... ........ 5-54 6.2.2 Distributed Operating Systems (DOS)...—------
5.4.3 Application 1.0 Interlace ............................. ......... 5-54
6.2.2(A) Data Migration ..............
5.4.3(A) Block or Character Devices ..................... ................... 5-55
62.2(B) Computation Migration
5.4.3(B) Network Devices...... . ..... .......................... 5.55
5.4 -3(C) Clocks and Timers......... ...................... 5.55 6.22(C) Process Migration .......
5.4.3(D) Blocking and Non-blocking VO....... ................. Syllabus Topic : Network Structure ...
..... 5-55
Syllabus Topic : Kernel I/O Subsystem ......... 6.3
..... 5-56 Network Structure ................................
5.4,4 Kamel VO Subsystem.........
6.3.1
5.4.4(A) VO Scheduling .......... Local-Area Networks (LANs) ..............
5.44(B) Buffering ,z.™............ 6.3.2 Wide-Area Networks (WANs) ....... -.....
5.4.4(C) Caching ....... ......
..... 5-57 ✓
Syllabus Topic : Network Topology -
5.4.4(D) Spooling and Device Reservation ..... 5-57
6.4
Network Topology...... ............
54.4(E) Error Handling ...................
5.4.5 VO Protection............ _ _ ..... 5-58 Syllabus Topic : Communication StnK
5.4.6
6.5
Kamel Data Structures ................ 5-58 Communication Structure .........
6.5.1
..... 5-58 Naming and Name Resolution...
65,2
touting Strategies .....
5.4.5
..... 5-58 65,3
............... Jacket Strategies........
6.5,4
Syltabue Topic: STREAMS... ............ ..... S’SB Connection Strategies
5.4.6 STREAMS ......... 6.5,5
.... 5-59 Contention........
z Syllabus Topic : P ertOrmance ’ ’ .............. . ........
...... 5-59
5.4.7 Performance ..... ....... ....... -..... . 6.6
...... 5-60
Convocation Protocols..
5,5 Exam Pack (Untamty and
...... 5-6o s
yllabu» Topic : Dislributed HI® SV5 '
6.7
...... 5-60 DhWb
«W FHb Sy8t8ms. ........
Scanned by CamScanner
|( |* Operatktg 7 Table of Contents
v
6.8 Naming and Transparency ............................................... 6-10 Syllabus Topic : Concurrency Control ........................6-1 6
6.13 Concurrency Control .......................... 6-16
6.8.1 Naming Structures .............................................................. 6-1 0
6.13.1 Locking Protocols .............. 6-16
6.8.2 Naming Schemes ................................ ..... 6-1 1
6.13.1(A) Nonreplicated Scheme ....................,.......................... ..b-16
6.8.3 implementation Techniques . ....... ............................... 8-1 1
z Syllabus Topic : Remote File Access .,.......... 6-12 6.13.1(8) Single-Coor dinato r Approach .......................................... 6-16
6 9 Remote File Access ...... .................................................... 6 - 1 2 6.13.1(C) Majority Protocol .................... ..... .....................................6-17
6.9.1 Basic Caching Scheme ..................................................... 6-12 6.13.1(D) Biased Protocol ........................................... ...................... 6-17
6.9.2 Cache Location ........ ................................................... 6-12 6.13.1(E) Primary Copy .............. ................. ..... ............... 6-17
6.9.4 Consistency..., ........... ............................ 6-13 6.13.2(A) Generation of Unique Timestamps ................................. 6-17
6.9.5 A Comparison of Caching and Remote Service. ......... 6-13 6.13.2(B) Timestamp-Ordering Scheme.. ......................... ............6-18
✓ Syllabus Topic : Stateful Versus J Syllabus Topic : Deadlock Handling .......................... 6-18
Stateless Service.,...,.... ................... 6-14 6.1 4 Deadlock Handling ....... ......... ,6-18
6.10 Stateful Versus Stateless Service ............ ..................... 6-1 4
6.14.1 Deadlock Prevention and Avoidance. ............ ............. 6-18
✓ Syllabus Topic : File Replication ............. ....... 6-14
6.14.2 Deadlock Detection.... .......... ................................ 6-19
6.11 Ale Replication.. ................... ;................................... 6-14
6.14.2(A) Centralized Approach .................................................., . . . 6 - 1 9
✓ Sy I lab u s Topic : Distributed Synch ronization ............ 6 - 1 5
6.14.2(B) Fully Distributed Approach..... .......... .......... ........6-19
6.1 2 Distributed Synchronization. .................... ;.......... 6-1 5
6.15 Exam Pack (Review Questions) .................. ................... 6-20
6.12.1 Mutual Exclusion ......... . 6-15
• Lab Manual ___________________________L T to L-26
6.12.1(A) Centralized Approach ........ ................................ 6-15
□□□
Scanned by CamScanner
CHAPTER Module I
~ ®yl,abua J?P'S..
1 mana
storage management, Protection 7 n <1 security oXteXnd ZT" 9eme " k
Structure: Operating system services and interfaro e „ P C a purpose Systems; System
SyS,em
Operating System Design and ZtemeZ ion Os' X, X T rams,
lrn
generation. System boot Pl e m 6 "'o p on, OS structure. Virtual machines, OS debugging and
Syllabus Topic ; Introduction unii to complete the execution and computer system
should offer the service to allocate processing uni"
to
users program.
The operating system allocates
memory to user
program as per need.
What ts OS?
In the same way, user programs interact with the other
user programs through devices like key board or a
Q- What is operating system? mouse or even a joy stick.
ne 2015, Nov. 2015, 2 Marks
Syllabus Topic : Operating System Structure
An operating system is system software which
manages, operates and communicates with the computer 1.2
hardware and software. To complete the execution user
program need many resources. The main job of the
K r ----- uc vices
usy all the time, operating system supports
user program. So without operating system, a computer multiprogramming.
would be useless. In multiprogramming, operating system organizes the
jobs in such a way that the CPU always get one job to
execute, Hence, Multiprogramming improves CPU
An operating system acts as an interface between the utilization.
user and hardware of the computer and also controls Multiple jobs remain in memoiy so that CPU can take
L
execution of application programs.
Operating system is also called as resource manager. does not
Scanned by CamScanner
Overview of Operate
StnMUrt
organic
1ST Operating System (MU - Sem 4jTj
1 . Monolithic Systems
2 . Layered Systems
3. Client-Server Model
handled b y tbis la
locate space for proc5f
Scanned by CamScanner
Operating System (MU ■ Sem 4 - IT) 1-3 ______________________Overview of Operating System
If (here is no space i n main memory, then it also An operating system layer is an implementation of an
allocates space on a 512K word drum used for holding abstract object made up of data and the operations that
parts of processes (pages). can manipulate those data.
The layer 1 software was concerned of making needed A characteristic operating system layer consists of data
pages were brought into memory' whenever they were structures and a set of routines that can be invoked by
required, higher-level layers.
The same layer can too invoke operations on lower-
level layers.
The operator
1 ...
User programs
__________ Layer irX
3 / Layer n-1
InpuVoutput management
[ _____ I
Layer 0
Operator-process communication
ka,ion betw n each PTOe and ,he It keeps muuh better control over the computer and
“ “ “ “
oXr
Layer 3
con'X e C h Pr
’ “ eSS effcCliVCly had
’, S Own Implementors have more liberty in changing the
ntemal workings of systen J
modular operating systems.
P* management of I/O devices and buffering the
slreams and from thcm was handl
MsXr «* b y
ahi8herlayerCMS UleVM/370g0tal0t
f of S imX '
astern XulTT ‘ he WayS
°“d ° approach 10 make
shown
Fig- 1.23, the onenf in
g SyMem 1S broken up int0 a
number of layers. “
; g a
XT i“ « «s iX .
h the hardware
the highest layer\s hv ° ’*
A trend in modern
■-------— N, which is the user interface. a
of moving code ui
Scanned by CamScanner
Overview of Operate- ■
Scanned by CamScanner
Operating System (MU - Sem 4 - IT)
1-5
__gvgryiew of Operating System
Difference between monolithic and microkernel
It is more flexible. A n y module can be replaced. I t is not flexible as compared to microkernel. Its
component cannot be changed, without doing a
total shutdown and perhaps even a full
8, Drawbacks
Scanned by CamScanner
13.2 Timer
_„ l clocks containing crysy
„ k.™, -M - — »
sta
Scanned by CamScanner
Overview of Operating System
'rating System (MU - S e m 4 - I T )
system. To execute the program, user needs to keep the
A program gets executed in main memory. So it should program in main memory .
be transferred from disk to main memory.
The main memory is volatile. Therefore a user needs to
To complete execution, program needs many resources store his program in some secondary storage which is
non volatile.
files etc
naw it becomes process. From the computation context Every process needs main memory since a process
code, stack, heap (dynamically- allocated structures),
X oMiew. a process is defined by CPU state,
memory contents and execution environment , and data (variables) must all reside in memory.
Process manager implements the process management The management of main memory is required to
support for multiprogramming. Many executables
tomnWrogramming. single CPU is shared among processes exist in main memory at any given time.
Different processes in mam memory have different
kX processes remain busy in completing UO CPU address space.
is allocated to only one process at a given point of time.
Memory manager is the module of the operating system
Here *some
— , [policy is required to allocate CPU to
J ess, called as CPU scheduling.
L users working on the system, operating Programs after completion of execution move out of
If multiple
system switches
i ------- the CPU from one user process to main memory or processes suspended for complehon
The process management activities involves . The memory management activities handled by
operating system are :
1. To provide control access to shared resources like
file, memory, I/O and CPU. L Allocation of memory to the processes.
2. Control the execution of user applications, Free the memory from process after completio
3. Creation, execution and deletion of user an execution.
system processes. Reallocation of memory to a program after used
4. Resume a process execution or cancel it. block becomes free.
5. Scheduling of a process. 4. Keep irack of memory usage by the process.
6. Synchronization, interposes communication an
deadlock handling for processes. *" Syllabus Topic : Storage Management
Scanned by CamScanner
1-8 -
— j, volatile. Storage devices and k
Tr - - - -— Main memory «
devices are used ‘ ssjon
system
devices
. Storage dev
(network c
The OS abstracts from the phy»“J Pr the
o The information should not loss after termination The hard disk is used as main storage device in your
of the process using it.
o Several processes must be able to access the Within one hard disk unit, many physical disks are
information simultaneously.
In order to fulfill the above requirements, it is Several metal platters are present within the hard disk
necessary to store information on disks and other
and these are coated with a special magnetic material.
secondary storage in units called files.
The platters rotate many thousands of times within a
A file is a named collection of related information that
is recorded on secondary storage.
second for accessing the data. Magnetic read and write
Creation Md 6 PUt
’■ deletion of files and d - partitioned ana °f hard disk
- Hard disk can *
2 partl,ion
- -mvide access to fi ,es J
and
drive. Storam. can be used as sepa1
We for files. Nation of storage
or terabytes °f hard
“ink can be in gig
’• Wnback-apof
iheprtauti .
for
Atones. Elating Qles
driver. ntrol and monitor the
1.6.2
Ca
Q. chin g
“Wain how
Scanned by CamScanner
1-9 Overview of Operating System =
System (MU - Sem 4 - IT)
can be in gigabyte or terabytes. For magnetic disk,
The memory system can be viewed as hierarchy of 4 typical access time is around 10 nanosecond and
layers Top layer contains many registers which are storage capacity is around 1 to 4 TB.
inside the CPU.
The recently read data remain in disk cache. Sometimes
As material used to build the registers and CPU is adjacent data which is expected to be accessed next
same, these registers are faster just like CPU. time is held by disk cache. Some disk cache offers
These registers can be accessed quickly. For these write caching also.
registers, typical access time is around 1 nanosecond
1.6.4 I/O Systems
The second layer of the hierarchy is cache memory. As we know that I/O is one of the main functions of an
The frequently used data and instructions are cached in operating system and is used to control the entire
computer’s Input/Output devices.
memory is controlled by the hardware.
Basically it should have to issue commands to the
The division of primary memory is done into cache devices, catch interrupts, and handle errors.
lines of 64 bytes, having addresses 0 to 63 in cache line
It should also provide an interface between the devices
0, 64 to 127 in cache line 1, and so on. The most
and the rest of the system that is simple and easy to use.
frequently used cache lines are kept in a high-speed
The I/O code represents a significant fraction of the
cache sited inside or very close to the CPU.
total operating system. Computers operate with many
If cache hardware finds that, needed line by program is
kinds of devices.
in cache then it is cache hit.
As we know that it include storage devices (disks,
If it is not in cache then it is treated as cache miss and
tapes), transmission devices (network cards, modems),
needs to pay for more time as request would be
and human-interface devices (screen, keyboard,
satisfied from main memory.
mouse).
For cache, typical access time is around 2 nanosecond
Following are the components of I/O subsystem.
and storage capacity is around 4 MB.
o Buffering, Caching, and Spooling which are
In main memory, a buffer is reserved for disk sectors
memory management components.
called as disk cache.
o Device driver interface.
The cache keeps a copy of data in some of the sectors
on the disk. o Drivers for specific devices.
- To fulfill an I/O request for a particular sector, first '"""s n busTopIcTprotection and Security___
disk cache is checked to see whether the sector is in
disk cache.
1.7 Protection and Security
If it is present, then request is fulfilled via the cache. If
not present, then required sector is read into the disk
cache from the disk.
- Protection mechanisms refer to the particular operating
The disk cache improves the performance as some
system mechanisms which are used to protect
request is satisfied from it.
information, files and resources in the computer.
The property of locality of reference is used .When a
- Policy means whose data should be protected from
block of data is present in cache to fulfill a single I/O
whom and mechanism is how system put into effect
request, it is expected that same block will be needed in
these policies.
future.
- In some systems, a program called reference monitor is
Due to disk cache mechanism, time required to read
used to impose a protection.
from and write to hard disk is improved. Now days it is
the part of hard disk. - Any attempt to access the resource is verified by
reference monitor whether it is legal or not.
Hard disk can be partitioned, and each partition can be
used as separate drive. Storage capacity of hard disk
Scanned by CamScanner
of Operating s
- Sgm
The referee makes a decision on
n the basis Of policy
security- m tb C particular ope
1 used
table. . . developed to protection n*' ""' wbic h are to pro |
Modem protection sysle m in which ~ reechan . security encomp
improve the reliab.hty of « P information re ty.
use of shared resources » inv n
rail problem Thre e of more
There are many reasons to offre lo avoid Seci
arc nature of rite threats,
ones THe
h ts needed to prov.de the .0
mischievous, deliberate vtolahon o
nature of intruders.
rr Tmahc sure that, each ram o Accidental data loss.
o
component ringin the system uses system
„ per defined policies to ensure the rehab.l y 7 1 Threats
SySlero
uiewnoint of security, computer systems
r .he resources of computer From
Policies to make use of the resources *. Ls wi* corresponding
three general goals. threats to them,
system are put into effect by mechamsm wh c
offered by protection.
These are shown in f i g - • ■
Scanned by CamScanner
RPT Operating System (MU - Sem 4 - IT)
— - - verview of Operating System
■4 3. System availability
Process often switches from user area to kernel area,
- System should be usable at any time. Nobody should tnat is, from one domain to other.
disturb the system to make it unusable. The kernel part has access to a different objccls
- During execution, processes can go from one domain to A distributed system should allow for scaling it.
other domain. The rules for domain switching are very Distributed system should support for availability. It
much depends on and varies from system to system should be always available to the users and applications
- In Unix every process is defined by user-id and group- in spite of failures.
id(uid.gid). Failure handling should be hidden from users and
- Two processes with the similar (UID, GID) applications.
combination will have access to precisely the same set
of objects.
Scanned by CamScanner
eratinq s
Multiple. same
Possibly aN Protocol is set of rules by which Compaq
One, shared
Operating
different communicates with each other.
systems
Each node Many protocols are present such as router.
One, shared
One, shared
Filesystems protocols, host-host protocols, and others. Prot«;01
has own
stack layers different protocols on top o f one another
Many
Administration One organization f One This protocol stack is used by all modem network
organization
Different layer in protocol stack deal with differ
issues.
Network contains computers with different
architectures (heterogeneous). Most of the distributed systems use the Internet as a
base. Hence, these system uses two important Internet
this heterogeneous environment, a middleware layer is protocols: IP (Internet protocol) and TCP
often placed between higher layer that comprises of (Transmission Control Protocol),
user and applications and lower layer comprising the I P (Internet Protocol) is a datagram protocol. In IP, a
operating system and communication facilities. sender sends datagram of up to 64 KB over the network
- This organization of distributed system is called as and no guarantees are given for its delivery.
middleware is shown in Fig. 1.8.1.
Computer A Computer B Computer C
The datagram may be fragmented into smaller packets
and travel independently, possibly along different
routes.
Distributed Applications
Scanned by CamScanner
Overview of Operating Systern
\ 1?t |nq System (MU -Sent 4 - I T )
Scanned by CamScanner
Qveryi
:
Synchronization' —
witfl and responding to the _J* for example pabi
o Efficient movement or □
out coordination among these processes.
-> 19.2 Multimedia Systems Faster processors need more power. So it is obvious
that, handheld devices require large battery size and
Apart from conventional data, now days operating
will occupy more space for battery.
system should be able to handle multimedia data.
Therefore most handheld devices use smaller, slower
Multimedia data comprises audio and video files as
well as conventional files.
Multimedia data should be delivered to the application As a result, the operating system and applications must
in defined time constraint. E.g. Video frames must be be designed not to toll the processor.
streamed as 25 frames per second.
The final issue deal with program designers fof
Multimedia depicts a broad range of applications that
handheld devices is I/O. A short of physical space
are in well-liked use today.
restricts input methods to small keyboard: , handwriting
These comprise audio files such as MP3 DVD movies
vdeo conferencing, and short video clips of movie recognition, or small screen-based keyboards.
previews or news stories downloaded over the Internet rnall display screens also provide constraints on
Multimedia applications may also , output options.
broadcasting over the World Wide Web Fn
— u! display for a handheld device limits to 3
broadcasting of speeches or sporti „ g evems
Multimedia applications include comhinw ,
"" p’8” ■“
b
audio and video. For example, a movie m a”" °*h
separate audio and video tracks. * C °" S ' S ‘ Of
•*
Scanned by CamScanner
Overview of Operating System
/gTcoerabng (MU - S e n 4 : IT
This involves the use of I/O. During execution,
Ayllnbus Topic: Operating System Services program requires to perform I/O operations for input or
output.
Until I/O is completed, program goes in waiting state.
-> (May 16) I/O can be performed in three ways i.e. programmed
I/O. Interrupts driven I/O and I/O using DMA. The
• Torvices provided by operating system.
Q.
M U ■ M a y 2016. 5 M a r k s
underlying hardware for the I/O is hidden by operating
system from users.
Following are the six services provided by operating These I/O operations make it convenient to execute the
system for efficient execution of users application and to user program.
Operating system provides this service to user program
f Operating System | for efficient execution.
Services |
-4 4, File System Manipulation
1. User interface - Program takes input, processes it and produces the
output. The input can be read from the files and
■ 2. Program Execution produced output again can be written into the files.
This service is provided by the operating system. All
files are stored on secondary storage devices and
4. File System Manipulation manipulated in main memory,
- The user does not have to worry about secondary
t 5. Communications storage management.
- Operating system accomplishes the task of reading
a f 6. Error Detection
from files or writing into the files as per the command
specified by user,
1. User Interface - Although the user level programs can provide these
services, it is better to keep it with operating system.
User interface is essential and all operating systems
- The reason behind this is that, program execution speed
provide it. Users either interface with the operat.ng
is fundamental to VO operations.
system through command-line interface or graphical
5, Communications
Cooperating processes communicates with each other.
Command interpreter executes next user-specified
If communicating processes are running on different
command. A GUI offers the user a mouse-based machines then messages are exchanged among them
and they gets transfer through network.
■4 1 Program Execution This communication can be realized by making the use
- The operating system provides an environment to run of user programs by customizing it to the hardware
that facilitates in transmission of the message.
users programs efficiently.
Customization of the user programs can be done by
- The resources needed Io the programs to complete means of offering the service interface to operating
execution are provided by operating system ensuring system to realize communication among processes
optimum utilization of computer system. distributed system.
- Memory allocation and deal location, processor In this way the communication service will be provided
allocation and scheduling, multitasking etc functions by operating system and user programs from will be
are performed by operating system. free from taking care of communications.
management. User program does not given these rights. - In order to prevent the entire system from
malfunctioning, the operating system continually keep
-4 3. I/O Operations
watch on the system for detecting the errors.
- Each program requires cannot produce output without
taking any input.
Scanned by CamScanner
Overview of Operatii
2. Memory Management
Q. Explain different objectives of operating system.
5
M U - J u n e 2015. N o v 2015. 4 M a r k s 3. File Management
Scanned by CamScanner
Overview of Operating System
Scanned by CamScanner
Overview
======= =s===S=of Operating
= ==S5Si:5s |
1-18 1 1 1
____== = l]
— to t be calling program r—
Ing System (MU - Sem After this, control returns
==
persists executing. _ _________ _________ I
Syllabus Topic : System Calls
The kernel warily makes sure that the request is valid 2. Manage computer resources
and that the process invoking the system calls has As several users and programs shares machine and i
devices, access to those resources must
synchronized.
kernel implements and ensures a fair access
If the whole thing is fine, the
-quest in kernel mode and can access The 7 SUCh Pr0CeSS
device dZiceT ° r’ thC memOly
dnvers in charge of c on tro U i n g the hardwarc
data of the calling process can . into effect isolation between processes
d
modified by kernel, as it has access to m “
space
' But - “ not execute any codeT' 7
“ ** process cannot
application, for clear security rcaS o n s . * ““
When the kernel finishes the ■
881 18
memory
-stores the process execution * * °f request
’ h
Scanned by CamScanner
Overview of Operating System
E Oosratinq System (MU ■ Sam 4 - IT) 1-19
A user process can explicitly request to enter in kernel q. Explain any five system calls.
mode by issuing a system call. MU - J u n e 2015. N o v . 2015. 6 M a r k s
During the execution of user process kernel can take These are
over to carry out some system housekeeping task.
The kernel mode is both a software and hardware slate.
Modem processors offer a advantaged execution mode, Types of System Calls |
Scanned by CamScanner
Overview of Operate.
1-20
4. Write
&
Sr. Group Examples
No. Writef ) is similar to read() system call, On]y
the bytes instead of reading them.
Information get time or dale, set time or
maintenance | date, It returns the number of bytes actually written
get system data. set system almost invariably "size". ’
data, 5. Create process
get process, file, or device
S3 *
attributes.
using create process system call. L
set process, file, or device
attributes The process which creates new process js
parent process, and the new processes are l
1.13.2 Some Examples of System Calls children of that process.
Soma examples of Newly created processes may in turn create .
nt
•ya fem calle
r r!
processes, creating a tree of processes. -’
1. Open
Syllabus Topic : System Programs
2. Close
1.14 System Programs •
3. Read
Q. Explain various system programs tha i ' "
4, Write ar
associated with operating system. '
Open system call request to the operating system for user interfaces to system calls and rest of the Sy
using a file.
The files path is used as argument to specify the file, Operating systems are supp | ied wjth
Pointed to by W. °n
Characteristically, these p rograms carries
formatting and . ,a
Scanned by CamScanner
1-21 Overview of Operating System
files or other output devices or display it in a Systems required for debugging the higher-level
window of the graphical user interface. languages or object code arc also offered.
o Communications : Some of the system programs
o File modification : System program such as text
offer the way for creating virtual connections
editor is used to create and modify data or
information in files stored on disk or other storage among processes, users, and computer systems.
They permit users to exchange messages, to
devices. Some particular commands are used to
browse web pages, to send electronic-mail
look for contents of fifes or carry out conversions
messages, remote login and transferring the files
of the text.
from one machine to another.
o programming-language support : The language
translators such as compilers, assemblers, Just like the system programs, many applications too
interpreters come with operating system to are the part of operating system.
translate the user programs to object code. These programs are called as system utilities or
Scanned by CamScanner
1'22
MU -
Explain design goals of oporadng system Jv over CPU-bound jobs or to support the
microkernel design.
_ Consequently, it allows to add more
mechanisms and policies by means of userJ
kernel modules or by means of user pregr j
themselves.
system. The allocation of resources should be on the bad
i. These
policy decision.
requirements are categorized in two fundamental
1,15.3 Implementation
groups: user goals and system goals.
q. Explain implementation of operating sys
use, simple to learn and to make use or u. reiwuis, design.
and protected and having high performance.
Traditionally assembly language was used
Due to lack of general agreement on how to accomplish implement the operating system.
these goals, the above properties are not useful in the Now high level languages arc used to implement I
design of system. operating system.
Person responsible to design, create, maintain, and Due to this code is easy to read, understand and del
operate the system also desires the properties like: and implementation process became faster.
Simple to design, implement, and maintain, flexibility, After recompilation operating system can be ported
reliability, error free, and efficient. Such requirements other machine.
are unclear and may be inferred in different ways. On the other side, if high level languages are use(
Single solution to the problem of defining the implement the operating system the speed will
requirements for an operating system does not exist. reduced and storage required would increase.
The different systems in existence show that different These issues are negligible as assembly W
requirements can leads to a large diversity of solutions routines can be developed for large progrnins
for different environments.
compilers can optimize the code.
1.15.2 Separating Policies from Mechanisms The operating system routines responsible
bottleneck can be replaced by assembly W
- MecW sms decide the way of doing something
whereas policies determine what will be done. In this way performance can be improved. Use of*
It is necessary to keep policies
data structures and algorithms also impro
performance.
mechanisms to achieve the flexibility
system performance.
Scanned by CamScanner
1-23 Overview of Operating System
0 Sem4
I TooeratingSy - IT)
1,16.1 History
Bottlenecks can be identified by monitoring system
pc rformance.
Internet standards virtual machines were also present
n atinc system should include the code to calculate
earlier. Around I960, IBM developed two hypervisors
Xdisplay measures of system behaviour.
SIMMON and CP-40 which was research project.
In many systems, the operating system carry out this
CP-67 was reimplemented version of CP-40. CP-67
iob by producing trace listings of system behaviour.
AU necessary events are logged with their time and formed the CP/CMS which was virtual machine OS for
important parameters are written to a file. the IBM System/360 Model 67. In 1972, CP-67's
reimplemented version was launched as VM/370 for
Syllabus Topic: Virtual Machines the System/370 series.
In 1990 IBM replaced System/370 by System/390. In
all this journey, although machines were renamed but
1,16 Virtual Machines underlying architecture remained unchanged to
maintain backward compatibility.
q. What is virtual machine? There was better improvement in hardware technology
and newer machines were bigger and faster as well.
By means of CPU scheduling and virtual machine
Over the period of time, although hardware technology
(VM) techniques, host OS can produce illusion that
improved, but virtualization was there and supported
each process has its own processor and memory. by all the machines.
- This memory is virtual memory. The VM offers an In 2000, IBM released the . z-series which was
interface that is the similar to the underlying bare backward compatible with the System/360. Z-series
hardware. had supported 64 -bit virtual address spaces.
The processes running are the guest processes and each All of these systems supported virtualization decades
process gets virtual copy of the underlying computer. before it became popular on the x86.
This guest process is a operating system. The early releases of OS/360 were strictly batch
In this way single machine runs the multiple operating systems. But, due to requirement, many 360 users,
systems in parallel, each in its own VM, decided to have timesharing, so various groups, both
From availability and security point of view, using inside and outside IBM decided to write timesharing
separate computer to put each service is more systems for it.
preferable by organizations. If one server fails, other The TSS/360, the first time sharing system, arrived late
will not be affected. and it was so big and slow that few sites converted to it.
It is also beneficial in case if organizations need to use It was finally neglected. And it its development cost
different types of operating system. was very high around some $50 million (Graham,
However, keeping separate machines for each service is 1970).
costly. Virtual machine technology can solve this But a group at IBM’s Scientific Center in Cambridge,
problem. Although this technology seems to be modem Massachusetts, produced a radically different system
but idea behind it is old. that IBM eventually accepted as a product, and which
- The VMM (Virtual Machine Monitor) creates the is now widely used on its remaining mainframes.
illusion of multiple (virtual) machines on the same
This system, originally called CP/CMS and later
physical hardware.
renamed VM/370 (Seawright and MacKinnon, 1979),
- A VMM is also called as a hypervisor. Using virtual
was based on an astute observation :
machine, it is possible to run legacy applications on
o A timesharing system provides
operating systems no longer supported or which do not
work on current hardware. o Multiprogramming and
Virtual machines permits to run at the same time o An extended machine with a more convenient
applications that use different operating systems. interface than the bare hardware.
Several operating systems can run on single machine The essence of VM/370 is to completely separate these
without installing them in separate partitions. two functions.
Virtualization technology plays major role in cloud
computing.
Scanned by CamScanner
Pe
Operating Sys tarn (MU - Sem 4 - IT] 1-24 Overview of ° gtin-
- The heart of the system, known as the virtu-1 machine monitor, runs on the h-rdwam
multiprogramming, providing not one, but several virtual machines to y up, ds ,
Fig. 1.16.1, \
Virtual 370s
Fig. 1.16.1
instructions. Some other instructions cause trap i f run network. The research and development in opera l
i n user mode called as privileged instructions. system is possible due to virtual machine concept.
If sensitive instructions are subset of privileged System remains unavailable till changes made rr
instructions then machine is virtualizable. tested in operating system.
In 2005, Intel and AMD added virtualization in their l i m e required for this is system development time.:
CPUs. On the Intel CPUs it is cal ied case of virtual machine, system development is done
(Virtualization Technology); on the AMD CPUs it is virtual machine instead of on a physical machine.
called SVM (Secure Virtual Machine).
The virtualized workstation permits for quick potM
and testing of programs in changeable enviromnatt
Scanned by CamScanner
nrwating System ( M U Sem 4 - IT) i -25
Overview of Operating System
In this manner, two lightly loaded system can be - The creation of exact copy of underlying machine
converted in one heavily loaded system. needs most of the work,
For extensive acceptance, the design of virtual - This underlying machine has user mode and kernel
machines must be standardized with the intention that mode, Since VM software is OS, it can run in kernel
mode.
any virtual machine will run on any virtualization
Platform. The VM itself can run in user mode. It is necessary to
have virtual user mode and virtual kernel mode.
be successful in combining virtu al -machine formats. Both of these modes must run in physical user mode.
Just like user mode to kernel mode transition on real
1,16.3 Simulation machine, there should be transition from virtual user
mode to virtual kernel mode on VM.
Because of virtualization, guest OS and applications
believes to be executing on native hardware. This transfer can be carried out as follows :
Simulation is other system emulation methodology like - System call by program running on VM in virtual user
virtualization in which host system has one architecture mode causes transfer to the VM monitor in the real
machine.
and compilation of guest system was carried out on
other architecture. VM monitor then alter the register content and program
counter for VM to simulate the effect of system call.
This is just like running instructions on new computer
system that were compiled on the old computer system. - The VM is the restarted which is now in virtual kernel
mode. Virtual I/O may take less or more time than real
- The programs could be executed in an elmulalor that
I/O. As CPU is being multiprogrammed among many
converts each of the old systems instructions into the
VM*s, they can be further slows down. For
native instruction set of the new computer system.
virtualization, hardware support is also important. All
1,16.4 Para-Virtualization general purpose CPU supports for virtualization.
within containers believe that only they arc Fig. C L I O : Examples of virtual machine
is difficult.
Scanned by CamScanner
Overview of Operas
---- --- »
1*26
tern (MU - Sem 4_J
pointer arithmetic, w ic
to run a number of
This permits this host system
in parallel as
different guest operating systems
his verification is successful then it i s
Java interpreter- The JVM also proves
Appikalfon
host OS. Three collection automatically-
- I n Fig, 1.162. Linux is running Windows
as NT. and The implementation of JVM can be carried
operating systems, free
software on the top of host OS or as a pan
Windows X P are running a-s
App|icatK>n browser.
Application
Appltoiton
The interpreter interprets bytecode one at a M
Guest OS
Guest O S faster interpretation is achieved by just in A
Guest O S (Windows X P ) -t)
(Windows NT)
(free BSD) Virtual CPU. compiler.
Virtual CPU.
Virtual CPU, Memory
Memory
Memory and devices
and devices and devices
and subsequent invocation of the methods a,c
Virtualization Layer
The guest file is the copy of host OS file in file system. Java
Interpreter
The guest instance of file is separate copied file due to
which protection of guest instant against disaster is
achieved. •
Host operating system
-> 1.16.6(B) The Java Virtual Machine (Windows. Linux, etc)
Scanned by CamScanner
1-27 _____ Overview ot Operating System
C# Source Code
to
I t is necessary to m<
discover bottlenecks.
MS-IL Assembly
This log
______ an analysis program to
17 operating SystemDguggl — -
the system to find bottlenecks.
debugging in detail. _______ ________ _
1 17.3 DTrace
Debugging includes finding hardware
system. Debugging activity is cam performance can _ DTrace ■ts the
the facility
I ? that permits
p r nroce
to kernel.
sses and add probes
dynamically in running user p
and software. By fixing the bugs tn system, pe
be improved,
Scanned by CamScanner
Overview of Operating „
128
The
Thc available devices, their device n Urtl > 1
rating S tem (MU* o and model of device .
using D program™ g
By giving query™™--; , hc kernel, -be mteX'pt number and characteristics.
am
language. surpd«"« irjc5 C an he determined, The preferred OS options, parameters
sysiem sure, and proves. _____ n user |evd ° used The number of buffers and size t 0 ‘
by values, the required CPU schedulmg a
CTdeWi
rhe maximum number of proce SSes
“*"‘'™' "'rbo-h the and
These (ootserN understands supported and so on.
ta mea. the rarera of lhe
A system administrator can use this infor
toolset should * aH
modify os source code.
andshoaMa. J av y i m t
The compilation of modified OS is then carried
produce output-object version as pe r
description.
ZZdl -se requirement, and oner safe,
Io another approach, tables are created and mod
dynamic, low imp«t debugging environment.
selected from precompiled library.
'Syllabm Topic : Oporatlng Systom GeneroUon__
next approach, complete table driven system Cj#
1,18 Operating System Generation created.
- The distribution of OS is usually done on disk, on CD- Q. Explain booting process of the system in detail
ROM or DVD-ROM. or as an "ISO" image.
The SYSGEN program reads from a given file, or The process of starting a computer by loading
request the operator of the system for information
relating to the exact configuration of the hardware A small program called as the bootstrap program <
system, or query the hardware straight way to know
about components present there.
memory, and starts its execution.
The following information is needed to determine.
O n some computer systems, for
o The CPU is to be used. Options installed like
two-step process.
nSttUC,i floatin
.T 2 "“ 8 Point arithmetic In first step simple bootstrap loader obtains a«
case of multiple implex boot program from disk, and this
CPU system.
Scanned by CamScanner
Overview of Operating System
When system starts up the RAM initially is in unknown Q. Explain layered system in detail.
state. ROM is suitable because it needs no initialization (Refer section 1.2.2)
- The characteristics of ROM go down somewhere q. Explain memory management function of operating
between those of hardware and tho.se of software. system. (Refer section 1.5)
Therefore all forms of ROM are also known as & Syllabus Topic : Storage Management
firmware.
Q. Explain file management in OS.
- For large size operating systems like Windows. Mac
(Refer section 1.6.1)
OS X and UNIX or for systems that change often, the
bootstrap loader is stored in ROM. and the operating Q. Write note on mass storage management.
system is on disk. (Refer section 1.6.2)
- In this case, the bootstrap runs diagnostics and has a Explain how caching Is implemented ?
Q.
small piece of code that can read a single block at a (Refer section 1.6.3)
fixed location (say block zero) from disk into memory
ur Syllabus Topic : Protection and Security
and execute the code from that boot block.
Q. Explain protection and security mechanism of OS.
1.20 ExamPack (Refer section 1.7)
(University and Review Questions)—
cF' Syllabus Topic : Distributed System
<r Syllabus Topic : Introduction What are the characteristics of distributed system?
Q.
q What is operating system? Explain. (Refer section 1.8)
Scanned by CamScanner
Overview of Operatii
id application program.
are
Sem 4 - 1 Comp
ffrrwetinoSyslemfW:
Q. Explain dinereni Q.
Q.
Q.
201 6) (Refer section 1.18)
(Refer section 1. 13) (5 Marks) (“ay
Syllabus Topic : Types of System Calls Syllabus Topic : System Boot
Q. Explain any five system calls. Q. Explain booting process of the system in
(Refer section 1.13. 1) (6 Marks) (Refer section 1.19)
(June 2015, Nov. 2015)
Syllabus Topic : System Programs
Scanned by CamScanner
CHAPTER
Process Management
*'9
>
Process concept : Process Scheduling, Operation on process and Interprocess communication;
Multithreading, Process : Multithreading models and thread libraries, threading issues; Process
Scheduling; Basic concepts, Scheduling algorithms and Criteria, Thread Scheduling and Multiple
Processor Scheduling,
•%l
program resides on the disk. On disk it does not require
2.1 Introduction _____________ _ _ _ any resources.
- Process manager implements the process management A program gets executed in main memory. So it should
be transferred from disk to main memory.
functions. In multiprogramming, single CPU is shared
among many processes. If many processes remain busy To complete execution, program needs many resources
in completing I/O, CPU is allocated to only one process and competes for it.
at a given point of time. Now it becomes process. From the computation context
Here some policy is required to allocate CPU to point of view, a process is defined by CPU state,
process, called as CPU scheduling. If multiple users are memory contents and execution environment.
working on the system, operating system switches the A CPU state is defined by the content of the various
CPU from one user process to other. registers such as Instruction Register (IR), Program
Counter (PC), Stack Pointer (SP) and general purpose
User gets the illusion that only he or she is using the
system. Process synchronization mechanism is required registers.
to ensure that only one process should use critical A small amount of data is stored in CPU registers.
section. Memory contains program code and its predefined data
structures.
Process communication, deadlock handling, suspension
and resumption of processes and creation and deletion Heap is reserved memory area for dynamically
of the processes etc are some of the activities allocation of memory to the program at run time.
performed in process management. In stack, program local variables are allocated and
return values of function call are stored. Some register
Syllabus Topic : Process Concept values are also saved in stack.
Execution environment includes open files,
Process Concept . communication channels to other processes etc.
Scanned by CamScanner
system
2.3 Context Switch B y using corr
"process executes procesa J>
2 runnmfl P , processes cu
Q. What is context switch 7 other. a
obtained.
------------------------- *. from one pro c e S . is die Process reqi
- When CPU switches f
1 U
belch job memory, file:
context switch occurs. pmcessi
switching Of .he CPU (Centre* Proe The subproci
one process or thread to another. Eve S f pr0WSS can get its nt
Fig . C12 = "‘ °
I r system, or it
When context switch occurs, ° * . ess f°
the infonnation of currently ex
g pr0C
to the s
System taiaaltotton I of the parent
later use
.... g naets
d
the f ter booting'OS cma'es many process V The parent <
or it can div
process. i
execution. ' . process If running P«*“ s eMCUte5
J I f child pro
Control Block (PCB) of a process. address Currently executing process creaus I subprocesst
The infonnation needs to be restc executed recesses by isswng create process 1 sysle The initial
Scanned by CamScanner
2-3
— — -vaiipicie information for al] Process Management
processes currently active in the syst e ra can OtteTwise, users could randomly kill Mch other s jobs.
obtained. is necessary that a parent requires knowing the
idenlitifec ,. *
Process requires certain resources like CPU time
, when a process creates a new process, the
memory, files, I/O devices io complete its task.
identity of the child process is passed to the parent.
The subprocess also needs these resources. Subprocess Any of the child processes execution can be terminated
can get its needed resources directly from the operating y child for a diversity of reasons, such as these :
system, or it may be forced to a subset of the resources
of the parent process. ° If the allocated resource usage is exceeded by
child. (The parent must have a means to examine
The parent can share the resources among its children
or it can divide the resources to allocate to its children.
There is no longer requirement of allocated task
If child process is restricted to a subset of the parent's to the child.
resources overloading the system by creating too many o In many systems, If the parent is terminated then
subprocesses can be avoided. OS does not permit a child to carry on execution.
The initialization data may be passed along by the For example, VMS system does not permit a child to
parent process to the child process after creation of the carry on execution after its parent process is
process. terminated.
After creation of a new process, two possibilities exist If all children of particular parent are terminated then it
related to execution : is called as cascading termination. After normal or
— The parent and its children both executes in parallel. abnormal termination of parent, cascaded termination is
carried out in much system. It is initiated by the OS.
- Until few or all the children terminates, parent will wait
and will not be terminated. In UNIX, exit() system call is used to terminate the
process. The wait() system call is used by parent to
With respect to the address space of the new process
wait until child is terminated.
again two possibilities exist :
The terminated child's process identifier is returned by
Program and data of child and parent process is same.
the wait() system call. Because of this process
It means child is duplicate of its parent.
identifier, parent process comes to know about which
— Program and data of child and parent process is child is terminated.
different. It means child process has a new program
- After the termination of the parent, the rnif process is
loaded into it. assigned as parent to all terminated children.
2.4.2 Process Termination - This init process collects all terminated children's status
and execution statistics after termination of their parent.
Q, Explain process termination. J
- When process finishes the execution of last statement, 2.5 Process Control Block
it terminates. After this it request the operating system
to delete it by using the exit () system call. Just then,
Q. Explain role of process control block.
the process may return an integer to its parent process MU - Dec. 2014. 5 Marks
by using wait() system call.
Q. Explain process control block. _ J
- Then all allocated resources to the process like physical
and vl&al memory, open files, and VO buffers are Any process is identified by its process control block
freed by the operating system. Termination can happen (PCB). PCB is the data structure used by the operating
system to keep track on the processes.
i n other situation also.
All the information associated with process is kept m
By executing the suitable system call, any process can
process control block. There is separate PCB for each
terminate the other process. Normally, parent of t e
process.
process to be terminated, executes this system call.
Scanned by CamScanner
process m
2-4
PrOS
MU'Sen ' „ x‘ s *’ ,ch
-
Operating System the status of
After c° nielc - reviously executing proc«Ss
urn of 0,6 P Eac
Treffree— * state When < ' „ts dlocated to it- Program
' *’* instruction f rorn is i
the processes. wh jC h arC in Uw” . hcr
7 - Ttogct
PCB’s of process;
linked M °f ,t,e Pn
(ready,
giving
executing.
executing
a specific name
- - |is , such as
in chain
j5.«— ** it)
linked toged-r
RefllB,er ’
c
Of all these pn* . che cks the 5 gene
It inclu* ” u m
w ,ingf0 a C l n,raffiC fOf ,he
I f "device become.
?X L f-« ' « process i* w.i>i”8
,s
again H P,acca 2 5.1.
AccoU nt fl ca)culating the process’s
device again I. b. l. o _i.
c k ie
M jchown in rifr
A icaJ processed!’ Information™
Current Sure relative to othe P information
Pointer
This may me inc i u des amount Of
Process ID
Accounting
Lt register. It includes paging. segmentation re
is waiting.
This field points to other process’s PCB. The After creation o f the process, hardware registers
scheduling list is maintained by pointer. flags are set as per the details supplied by loaders or linker
Current state Al any time the process i s blocked, the processor registers
F
content are generally placed on the stack and the pointer
Currently process can be in any of the state from new,
the respective stack frame i s stored i n the PCB. In ihh
ready, executing, waiting etc as described above.
fashion, the hardware state can be restored when the process
Process ID
is scheduled and resume execution a g a i n .
Identification number of the process. Operating system
assign this number to process to distinguish it from 2.6 Process States and Process State
other processes.
r
_ _ _ _Transition Diagram
Priority
currcnt
stat ° W S five states.activity
state contains of the process. Pro®9
Scanned by CamScanner
Operating System (MU - S e m 4 - IT) 2-5
- — - . Process Management
N. Each process remains in one of these five states. There - When the process is created, it remains in new state.
After the process admitted for execution, it goes in
is a queue associated with each state of the process.
'S Process resides on that queue as per the state in which
-
ready state.
A process in this state, wait in the ready queue.
State* of Scheduler dispatches the ready process for execution
proc*** model i.e. CPU is now allocated to the process.
~ When CPU is executing the process, it is in executing
1 . New state state. After context switch, process goes from
Of executing to ready state.
2. Ready state
If executing process initiates an I/O operation before its
is
allotted time expires, the executing process voluntarily
3. Execution state
give u p the CPU.
4. Watting (blocked) state - In this case process transit from executing to waiting
state. When the external event for which a process was
5 . Terminated state
waiting happens, process transit from waiting to ready
Fig. C23 : States of Process Model state.
- When process finishes the execution, it transit to
-> 1. New state
terminated state.
The new process being created.
-> 2. Ready state 2.7 Process vs. Thread
A process is ready to run but it is waiting for CPU A thread is a single sequence stream within a process.
being assigned to it. Threads are also called as lightweight processes as it
*♦ 3. Executing state possess some of the properties of processes. Each
A process is said to be in running state if currently CPU thread belongs to exactly one process.
is allocated to it and it is executing. - In operating system that support multithreading,
■4 4. Waiting (blocked) state process can consist of many threads.
A process can’t continue the execution because it is - These threads run in parallel improving the application
waiting for event to happen such as I/O completion. performance. Each such thread has its own CPU state
Process is able to run when some external event and stack, blit they share the address space of the
happens. process and the environment.
> 5. Terminated state - Threads can share common data so they do not need to
The process state transition diagram is shown in Like the processes, threads also have states like ready, •
Fig. 2.6.1. executing, blocked etc. priority can be assigned to the
threads just like process and highest priority thread is
New
scheduled first.
- Each thread has its own Thread Control Block (TCB).
Submitted Finished Like process context switch occurs for the thread and
Interrupt
register contents are saved in TCB.
Ready Executing
- As threads share the same address space and resources,
synchronization is also required for the various
activities of the thread.
I/O or event completion I/O or event
Scanned by CamScanner
ratin em MU ■ Thread OP 6
Multiple Multiple redundant processes use more resources With compare to multiple red
resources than multiple threaded process. process, multiple threaded processes n
fewer resources.
Address space Context switch flushes the MMU (TLB) No need to flush TLB as address
registers as address space of process changes.
remains same after context switch bee
Ready queue
Process Scheduling CPU
2?
— -k =Pt«respecti vedevjce * Pedlar
8 281 1 Uin8 <liaBran
Of“n
of ‘ ’
scheduling
Scanned by CamScanner
Process Management
I fgpi*O0ara tinHSystem(MU-Se m4-IT) 2-7
- When process state transition take place from new to
/ ' After allocation of CPU to the process start the
ready, then there long term scheduler come into picture
I I execution. While executing the process, one of the
for scheduling purpose.
N I numbers of events could occur.
j
I I the process finishes the execution, it travels 2.8.1(B) Short-term Scheduler
I I between various scheduling queues. The operating
Q. Explain short-term scheduler.
j I system selects the processes from queues based on
I some policy. - Processes which are in ready queue wait for CPU. A
I I - This selection is carried out by the program called as short term scheduler chooses the process from ready
I scheduler. There are three types of schedulers to queue and assigns it to the CPU based on some policy.
| schedule a process. These are shown in Fig. C2.4. - These policies can be First Come First Served (FCFS),
Shortest Job First (SJF), priority based and round robin
F Three type* •ch»duteri»”l
I to Bchedute a procw | etc, Main objective is increasing system performance
by keeping the CPU busy.
Lj (A) Long-term Scheduler - It is the transition of the process from ready state to
running state. Actual allocation of process to CPU is
I ' L> (B) Short-term Scheduler
done by dispatcher.
! L+ (C) Medium -term Scheduler I Short term scheduler is faster than long tern scheduler
and should be invoked more frequently compare to
I Fig. CZ4 : Types of scheduler long term scheduler.
When programs are submitted to the system for the - If the degree of the multiprogramming increases,
purpose of processing, long term scheduler comes to medium-term scheduler swap out the processes from
know about it. main memory.
- Then its job is to choose processes from the queue and - The swapped out processes again swapped in by
place them into main memory for execution purpose. medium-term scheduler.
CPU bound processes require more CPU time and less This is done to control the degree of multiprogramming
I/O time until execution completes. or to free up a memory.
- On the contrary, I/O bound processes use up more time - This is also helpful to balance the mix of different
in doing I/O and require less CPU time for processes, some time sharing operating system have
computation. this additional scheduler.
The main job of the long term scheduler is to provide a
2.8.1(D) Comparison of Three Schedulers
balance mix of I/O bound and CPU bound jobs.
- The number of processes in memory for execution and Q. Compare the functions of different types of
degree of multiprogramming is related to each other. schedulers.
More number of processes in memory for execution Sr. Long-term Short-term I Medium-term ’
indicates degree of multiprogramming is high. Long No. Scheduler Scheduler Scheduler
term scheduler controls the degree of
1, Selects Chooses the Swap in and
multiprogramming.
processes from process from out the
If the average rate of new process creation and average
the queue and ready queue processes from
departure rate of processes leaving the system is equal
loads them and assigns it to memory.
then degree of multiprogramming is steady.
into memory the CPU. .
The Jong term scheduler is not present in timesharing for execution.
operating systems.
Scanned by CamScanner
2*0 ePa8S n9
r ’ ad 1
_ IO u
■ «tion and communication
a
IJ
Sbort-tenn S ynch ' “ shoold satisfied wtletl
tequiremenU other Synch
Long-term
Sr. Scheuler
Scheduler is in
No. Speed
very both '"“““Tfe requued to achieve the mu W
between pr0CeSSe
Speed is and term . nrocesses do communic 1
fast short _ Independen P proce sses may need to
than the short and
invoiced
scheduler other but coope Coopemdve processes
term than term
frequent
long
information-
scheduler.
communicates through shared memory Or '
term
long scheduler.
scheduler.
passing-
of No process
of
Transition
Message naming provides both functions, u
Transition state state transition'
passing ■has
process u the further benefit that it lends
process state
to
from Ready nation in distributed systems
from Ne* t0 implemei.—
Executing. multiprocessor and un
Ready- shared-memory
in Present in time
Minimal
Not present in
systems-
sharing sharing system.
time .. „ „ are
are the two primitives used io
time sharing Following
system.
system.
Processes are
passing : |
Select a new
Supply
10 swapped in and 1 1 send (destination, message) s
reasonable process
out for 2. receive (source, message) j
allocate to CPU
mix of jobs,
frequently. balanced
such as I/O This is the minimum two operations reqjjJ
process mix.
bound and processes to send and receive the messages.
CPU bound sends data in the form of a message to another pn
It has control Reduce the indicated by a destination. A process receives di
It controls
over degree of degree of executing the receive primitive, indicating the :
degree of
'■Message passiimg
blnad
2,
Particul °? ° nS comraon
-
q_ Shared memory
wil1 usuaU have only one
«®*wi X ilrr
Onns
iplemented: y ‘
W>CtS8
, Modus of Interpret <■
Om
---------------- --------------Z2 '"unicati( , ri
Scanned by CamScanner
System (MU - Sam 4 - IT) 2 -9
- _____ Process Management
o The blocking send and blocking receive : Until In operating system that support multithreading,
the message is handed over, the sender and process can consist of many threads.
receiver both gets blocked. These threads run in parallel improving the application
o The nonblocking send and blocking receive : performance. Each such thread has its own CPU state
After sending the message, the sender continues and stack, but they share the address space of the
its work but receiver remains blocked until process and the environment.
message is arrived to it. This permits a process to —
Threads can share common data so they do not need to
send one or more messages to a multiple use interprocess communication. Like the processes,
destinations as quickly as possible. Here receiver threads also have states like ready, executing, blocked
is in need of message so that it can resume the etc. priority can be assigned to the threads just like
execution . So it gets blocked until message process and highest priority thread is scheduled first.
arrives. — Each thread has its own Thread Control Block (TCB).
o Nonblocking send, nonblocking receive : Like process context switch occurs for the thread and
Neither party is required to wait. register contents are saved in TCB.
o The nonblocking send and non blocking receive: — As threads share the same address space and resources,
Both sender and receiver will not wait and both synchronization is also required for the various
will continue the work. activities of the thread.
Message passing system should give guarantee that
messages will be correctly received by receiver. 2.11 Types of Threads
Receiver sends acknowledgement to sender after Q. Explain user level and kernel level threads with
receiving the message. advantages and disadvantages.
Scanned by CamScanner
:
"' ; d
less time 3,14 ' oftboopp" 1
;mory
t0 process- a are ge0 erBlly TT more
S
--------destroying 316
.. Creation and «s r cost o
(nci
“ v ''
f allow * (he memory
iocaung _ —I threads
Kernel m * the
than he user threads.
1
iscW n k and deal
cream “’ d t n , ’ k erneH
BvelthrBa
J
XX threads
Up a ,a9
the S <r Ad**° hcdule another thread of I
while destroying Icss tin*- ’ .. Tifias
The Tough one thread in a process
- Both op - XX. no process even *0“ does not block lhe M
b l 0 ,B
' ' “’ t Xmainssa , n = ’ ftcl rfiead, and can
address 5p* e exin 1
? BJoc S °f ’
lcveldirc
° nal Pr0CeSS ' —Itaneously schedule multiple tu
h fhToX
nehieve high <* F Kernel can sim u < onrnultipI e processes,
rlevel ds
s h O wsthe»« level «”«
U9er from the same p thrMds
U3&ra««*
_ Kernel threads
create and manage
3
Kernel a
Syllabus T o p g -
process
2 ,1 2 MultithreadingModels
3 03
Explain van’ * *
Q.
, . fTLBand „ Hering the advantages of user level and fe,
" Xi treads, a hybrid threading model using
- Thread switching does register X of threads can be implemented.
doing CPU accounting. On y
need to be stored and reloaded again.
The Solaris operating system supports this hybr
. user level threads are platform independent, ttey can
model.
I n this implementation, all the thread manage™
. Scheduling can be as per need of application. functions are carried out by user level thread package
Thread management are at user level and do y user space. So operations on thread do not reqs
thread library. So kernels burden is taken by threading kernel intervention.
package. Kernels time is saved for other acuvittes
" Disadvantages of user level threads - the applications are multithreaded then it can I
advantage of multiple CPUs if they are available. 0
If one thread is blocked on I/O, entire process gets threads can continue to make progress even if
blocked. kernel blocks one thread in a system function,
The applications where after blocking of one thread
other requires to run in parallel, user level threads are
of no use.
Three types of
Z Kernel Level Threads multithreading models
In this, threads are implemented in operating system’s
kernel. The thread management is carried out by kernel. 1 , One to one
All these thread management activities are carried out
in kernel space. So thread context and process context 2. Many to one
switching becomes same.
3, Many to many
Scanned by CamScanner
gf Operating System ( M U - Sem 4 n) 2-n
-♦ 1. One to one model
Therefore concurrent execution of threads cannot be
- In this model relationship between user level thread and achieved.
kernel level thread is one to one. This type of relationship facilitates an effective
- It means that there is mapping of a single user-level context- switching environment, easily implementable
even on simple kernels with no thread support
thread to a single kernel-level thread.
3- Many to Many Model
Because of such type of relationship multiple threads
Many to many association exist between user level
executes in parallel leading to more concurrency.
thread and kernel level thread in this model. It means
However, since it is needed to create kernel thread for that more number of user-level threads are allied to
every new creation of user thread. equal or less number of kernel-level threads.
So application performance will be degraded. Windows The necessity of altering code in both kernel and user
series and Linux operating systems try to minimize this spaces leads to a level of complexity not present in the
problem by restricting the expansion of the thread one tone and many to one model.
count. OS72, Windows NT and windows 2000 use one
Like many-to-one model, this model offers an efficient
to one relationship model,
context-switching environment as it repel from system
jJ |J |J User level th roads calls.
The keen complexity offers the potential for priority
inversion and suboplima! scheduling with minimum
coordination between the user and kernel schedulers.
Fig. 2.12.1
In this model management is done in user space. When Syllabus Topic : Thread Li brads*
one thread makes a system call for blocking, the entire
process gets blocked.
2.13 Thread Libraries
User level threads
q Write note on thread libraries.
At a time only one thread can access the Kernel thread - Kernel level library <s supported by operating system
at a time, so many other threads cannot execute in The data structures and code remains in kernel space.
parallel on multiple processors.
Scanned by CamScanner
= s“ s=S=SS=
VfindoWS systems. Java threads
HC0Ce
System (M_U» ’ ° n ted using the W i 0 3 2 and
*0
of function in library » and Linux systems. <4
Hence any invocation , t a lo calhmctioncll.
i n use “ h set of f* atureS * aVallable jav
’ k
, bread libraries that
The
I [he main Ihre . API to manage and create the tfe
Following are
8ndjaVa
n r ) method in java program i s
today. Type* * I The
Thread Llt>r*[j2L— J Csingie threati i n J V M . <
level library.
. Pthreads define API for the creation of threads an Q. What are different threading issues?
synchronization. As it is a specification, the des.gn
Following are the threading issues that needs J
of operating can choose their own way or
implementation of specification. considered with multithreaded programs.
In deferred cancellation, thread to be cancelled checks starts up then some number of threads are created.
the flag to know whether it should be cancelled or not. These threads are then placed in pool and they waits or
work.
If server comprising these threads receives request it
In UNIX, process is
Once thread completes the requested work, it returns to
event is occurred. The sign f()r event
pool and waits for other work.
Scanned by CamScanner
process
Ruling =
get 11 opt
e<Julin Act
scn 1
dis
3
rente thread* set
MduU rg .
co
,re made in following situati
_ T!
Decision is n -
- A thread pool p vrdcs the * * . SCh
number O'
that caist at ony ofic P
’' )rtrg c A fter cr
.ystems that caano< a
' ch005 ingei ParC
threads. eSS K
When any P
fic
-» 2.14.5 ThrMd-Speel rf [hat
:keu of
_ Always threads of a Pnl d la offers beitefi'*' °
When process
p cess. Surely, -his shanng new process from ready q y
multithreaded programming. other reason. ■
selected.
Q
- On the other hand, i. , da(a is a
require IB own copy « f « rta
2. Preemptive
or user and kernel level model of threads place an
intermediate data structure between the user and kernel Fig. C2.10 : Types of scheduling algorithms
threads.
■4 1. Non-Preemptive
- This data structure is called as lightweight process, or
LWP. For user level library L W P is virtual processor to Non-preemptive algorithms are designed so that onct
schedule the application to run. process is allocated to CPU, it does not free CPU un
LWP is attached with kerne) thread and OS schedules
it completes its execution.
LWPs as kernel threads to run on physical processor. 2. Preemptive
With blocking of kernel thread, LWP also blocks and
Preemptive algorithms allow taking away CPU fro®
tace user lhread assoeiated w . h ih .s Lwp
process during execution. If highest priority process!
blocks.
arnves in the system, CPU from currently execute
Scheduler activation is the method f™
low priority process is allocated to it. It ensures
always highest priority process will be executing.
Dispa,cher
' and dispatch latency
schedule user threads on[o ' 6 appllcatlon
can hod term scheduler allocates CPU to ready pw6 '
an
Processor. available virtual
Scanned by CamScanner
Operating System ( M U - Sern 4 - IT)
2-15
dispatcher. Short term scheduler is fas t e r than long |em Syllabus Topic; Scheduling Algorithms
scheduler and should be invoked more frequently 2-1 S 2
- Scheduling Algorithms
compare to long term scheduler.
Scheduling algorithm. I
one process and starts running of other process is called
as dispatch latency.
(B) Shortest Job First (SJF)
Syllabus Topic : Scheduling Criteria
(C) Priority Scheduling
P2 03 ___
Scanned by CamScanner
lhe following examptf,
ga n SJF) algonth
Consi der
_
' fiS*
, iob first
--- -
< I
m.
~" -
Burst tiir
pree P!
P3 ____10 Turner
32 0 Tum*u
P£ _ _ _ _5
Pl 2? Averts
P2 _____
24 s 3 2. W
0 (3 - 0 )
P3 15 W
Turnaround time for P2 3
<8 -O) = 8
Turnaround lime
P4 V
88 32
(32-0) V
P4
Turnaround tin* for AV'
Turnaround time Pl
23
Average Jum >5
s 0
Wailing tin* ° r = (10 -0)=10
= 3 0 for P l
Waiting tin* for ** Turnaround
=r 8 for P2
Por P Turnaround time (23 - 2 ) = 2 1
Waiting tin* * 3 + 8) / 3 = 3 ‘66 forP3
Turnaround tune
Average Waiting tin* Turnaround time for P4 (38 - 3 ) = 35
is Signify 1 re t,me
'
waiting
T* BSU " ’Ttiw "and average „ Tunuu
Average Turnaround time
average ' un ’ aroU " . arrival varies = 0
vanes -order of job
Waiting time
= (10-l) = 9
r
. 2 16.2(B) Shortest J o b F W j ------------------ Waiting time f° P2
= (15-2)=13
Waiting time for P3
Q. = ( 2 3 - 3 ) = 20
= (0 + 9 + 1 3 + 2 0 ) 7 4 * 1
Average waiting time
]n P reem e
exe cution time with compare
- —
(SJ F) improves the averag , currenriy executing process, then the CPU will be g
- Ready queue is maintai it in the ready
i erfSc When a job comes m, insert newly arrived process.
Ton ite length. SJF minimizes the average
The preemptive Shortest Job First (SJF) is called
Scanned by CamScanner
Operating System (MU - Sem 4 - FT) 2-17
Process Manage ment
Turnaround time for P3 = (14 — 2) = 1 2
Turnaround time for P4 (38 - 3) = 35 P4 P3 P5 Pl P2
Average Turnaround time (23 + 5 + 12 + 35) /4 = 18.75 0 4 9
Waiting time for P l ( 1 4 - 1 ) = 13 12 24 34
average I/O burst to average CPU burst are used to Round Robin Scheduling is designed especially for
compute the priorities. time-shari ng systems where many processes get CPU
External priorities are assigned on the basis of factors on time sharing basis.
such as importance of the process, the type and amount In this algorithm, a small unit of time called time
of funds being paid for computer use, the department quantum is defined.
sponsoring the work, and other, often political, factors. CPU is allocated to each process for this time quantum
All these factors are not related to the operating system. period of time. To implement this scheduling, ready
Preemptive and non preemptive SJF is a priority queue treated as FIFO queue.
scheduling where priority is the shortest execution time The new processes go to the tail of queue and each time
CPU chooses the process from head of queue.
In this algorithm, low priority processes may never When time quantum expires, context switch occurs and
execute. This is called starvation CPU switches to other process which is scheduled next.
I
Solution to this starvation problem is aging. In aging as The time quantum is fixed and then processes are
time progresses, increase the priority of the process so scheduled such that no process get CPU time more than
that lowest priority processes gets converted to highest one time quantum.
priority gradually. If process is executing and request for I/O the process
goes in waiting (blocked) state.
The Gantt chart shows the result. After the completion of I/O, process again gets added at
the tail of ready queue. The time quantum should not
| Process Burst time Priority
be very small or very large.
1 _ _P l 12 4
If the time quantum is very large, the algorithm will
P2 10 5 behave just like FCFS.
Scanned by CamScanner
seeSSSS
sf hc five 9 ueuCS and its
System processes
such as memory size, priority of the process, or its type.
Scheduling algorithm for different queues can be
Ir IF
I I
Interactive processes r
different. The round robin scheduling algorithm can be
used for interactive processes queue and first come first
serve scheduling algorithm can be used for batch Interactive editing processes
processes queue.
Ii t fF
Batch process
I
Scanned by CamScanner
Operating System (MU - Sam 4 - 1
2-19
ueue Process Management
Scheduling
pr<XlB
queue- 2, Proce ’ * Pled is placed into
Q- Explain multilevel feedback queue schedUii?? -
basis but are run nni on an FCFS
algorithm. *
y qUCUeS 0 and
the pTOcess * I ate empty .
In multilevel queue scheduling processes are not less then this burs
\ of 8
or
permitted to transfer from one queue to the other Also priority to it tk U ing
8°™ gives highest
SS WU1 ate
queue assigned to the processes are permanent and C P U . finish i™T “ * the
bUKU nd
cannot be changed, leading to the low scheduling cost, burst * 8° °ff its next UO
but it is not flexible.
CSSe
mm \ lha are
milhseconds * reqoire
also * bu. below 24
The multilevel feedback-queue scheduling algorithm
8
processes can move from one queue to other. The CPU- lower priority than shorter pr e Y ’’ with
P4
2
1
2—
4 I
Scanned by CamScanner
Process
2-20 Sc
priority
(*) Pl L_ 4
P5
P2 16 18
is 0. proc*
t,rne
TAT WMiti 0 Finish TAT
Pl
Finish 0 85 priory time
priority proce
process 10
10 16 F
to
Pl 11 _3
H 1 P
P£ 1
P2
13
13
P2
1 18 r Ave
13 18_ _
P3 14 3
14 19 19
14 P3
P4 19 4
19 P4 6 Avei
9.6 6
P5 134 2
P5 13.4 («>Pr
Average
F<
emp,i
SiF(N
(2) t_ nprt ’' <’ )
is0
,| l i m e f O r a llp<«e '
Arrival
P5 _ _ _£
P4 P3 _ _ _[ 19
P2 9
4
1
0 Waiting
Finish tat
Process Priority time Finish TAT
time Process
Priority
time _ U(r,p
19 9
19
Pl 19 19
0 Pl
P2 2
2 P2
P3 3 7 7
P3
2 4 4
P4 4
P4
9 4
2 9 14 14 (iu
P5 P5 2
7 3.2
Average Average 9.2
Scanned by CamScanner
Operatii ig System 1MU - Sem 4 - IT )
2-21
Process Management
1 Process Priority TAT Waiting time
Process Arrival time
I (6-l)=5 Burst time
Pl (1'0 =0 P1
3 (18 - 5 ) = 1 3
1P2 (1 1 - 5 ) = 6 P2
J " --
P3 2 (11 - 0 ) = 11 (6- ]) = 5 P3
0
26
6 18
( 1 8 - 5 ) = 13 P2 (i2-l)=U (8-l) = 7
F 3 (11 - 5 ) = 6
I-------------- P3 (21 - 2 ) = 19
2 ( 1 1 - 0 ) = 11 ( 6 - 1) = 5 ( 1 2 - 2 ) = 10 1
P3
P4 (26 - 3) = 23 ( 2 1 - 3 ) = 18 j
Average 9.66 3.66
—
Average 15.25 | 8.75 ________j
Average TAT = (5 + J 3 + 1 1)/3 = 9.6
Average waiting time = (0 + 6 + 5)/3 = 3.66 Average TAT = ( 8 + 1 1 + 19 + 23)/4 = 15,75 ms.
Average waiting time = (0 + 7 + 10 + 18)74 = 8.75 ms.
(iii) RR
(ii) RR ( slice = 4 ms)
Following is the Gantt chart
Following is the Gantt chart
P3 P1 | P3 ( P1 P2 P3 P1 P2 P2 P2
P1 P2 P3 P4 P1 P3 P4 | P3
0 2 4 6 fl 10 12 13 15 17 18
0 4 8 12 16 20 24 25 26
P1 1 ( 1 3 - 1 ) = 12 ( 2 - 1) + ( 6 - 4 ) + ( 1 2 - 8 ) = 7
I Process TAT Waiting time
P2 3 (18-5) = 13 ( 8 - 5 ) + ( 1 3 - 10) = 6
P1 20 (16 - 4 ) = 12
P3 2 ( 1 2 - 0 ) = 12 (4-2) + (10-6) = 6
P2 (8-1) =7 ( 4 - 1 ) = 3 _________
Scanned by CamScanner
p3
L— Q 9
13
system 0
TAT Waith
p4
i— — — i— pfT (8-0) = 8 0
f P1 I - — L— — 10 0
L -------------J 5 Pl
1
0 2
WaitlngtimS (l OAl (9 0.4)
tat ( 9 - 1) = 8
Process (10-1)*9
0 =0
Pl (1- 9.53
Average
P2 (5-
07 2) 126
(26 Averag *
P3 <5 Average waiting tin*
(10-3)jL2
P4
13 13)
Average = 13 nis. Exampl® 2.17.5
Average i a i : 6.5 ms. consider the foliowing set ot processes having
millisecond
Average waiting time burst time 22ri—
Process CPU Burst time Arrival In*
Example 2.17.4 execution at
10 0
suppose mat the following process amve P1
cate 5
P2
Burst time
| Process Arrival time 2 2
P3
8
Pt 0,0 ____
Calculate average waiting time using tolkswin
0.4 4
J P2 scheduling algorithms.
1.0 1 FCFS
[ P3 (D
(2) SJF
Calculate average waiting time anu -------
using SRTF and SJF . (3)
2 t P3 = 3as
Solution :
(4) RR (slice
(i) Preemptive SJF is SRTF (Shortest Remaining Time
Next) Solution :
P1 P3 P2
l o 10 15 17
TAT Waiting time
Pi
Process Waiting time
Pl __________0 _________
P3
P2 (10-l) = 9 \
6.33
P3
Average TAT = (13 + 5 + l)/ 3 - fi „ ( 1 5 - 2 ) = 13
Average 7.33 _
2 ““'
W Non - preemptive SJF
Scanned by CamScanner
2-23
Process Management
(1) FCFS
P2 ____ PI
2 8 (2) SJF
0
(3) RR (slice - g)
process Waiting time Solution :
Pl (8 - I ) = 7 (1) FCFS : Following is the Gantt chart
P2 (4-2-i)=l
P1
| P2 | P3 | P4 | P5 |
w
n
o
I
P3
0
3 8 * 10 15 20
Average 2.67
Process TAT Waiting time 1
Average waiting time = (7 + 1 + 0)/3 = 2.67 ms. Pl 0
(3-3) = 0 1
Prinritv scheduling having priority range from 1 to 3.
I
( P2 (8-l) = 7 (3-l) = 2 1
respectively for process P l = 3, P2 = 2, P3 = 3 as
P3
oo
03
(10-2) = 8
ii
I
given.
P4 ( 1 5 - 3 ) = 12 (10 - 3 ) = 7
Folio w i ng i s the Gantt chart
P5 ( 2 0 - 4 ) = 16 1 ( 1 5 - 4 ) = 11
p3 P3
[ P1 | I |
Average 9.2 1 5.2
n 10 15 17
Average turnaround time = (0 + 7 + 8 + 12 + 16)/5
Process Waiting time
= 9.2 ms.
________0 ___________
Pl
Average waiting time = (0 + 2 + 6 + 6 + l l ) / 5
P2 ( 1 0 - 1) = 9
= 5.2 ms.
P3 _ ( 1 5 - 2 ) = 13
________ 7.33 ________ (2) SJF : Following is the Gantt chart
Average
(4) RR (slice = 2)
Process TAT Waiting time . ]
Following is the Gantt chart
P2 P1 P2 P1 P1 (3 - 3) = 0 0
1 P l ’ P2 P3 P1 Pl
o ' 2 4 6 8 10 12 Id lb 7
P2 (10-l)= 9 (5-l) =4
P5 5 each
time for
Calculate average waiting and
algorithm.
Scanned by CamScanner
rithms
5** doling al9° *° «**!» J
tting Sjgtg
proc
------(io5iL— — eemptive SJF
eandnor
p2,p«v
_P2,
jw*!*.. -—
LS-
Ls
’ J20-4KJ1
—- i_ ____. &
Average 2 ___
Average 3___
12.8 ms
12 4
wai il time
(8+ ‘
Average ' ’8
8.8 ms.
Solution •
(I) Hf°
Mtowinfl jobs to execute with one
Assume '**
Arrival time
CPU Burst time
Job
0
75 Hnlah
TAT
0 Process Priority
10 time
50
1
10 8 _ j8-0) = B
25
2 PI
80 9 (9-1) = B
20
3 P2 ____
85 12 ( 1 2 - 2 ) = 10
45 __________
P3 ____
id robin with quantum of 1 5. 14 ( 1 4 - 3 ) = 11
Suppose system uses rount P4
(i) Draw Gantt chart 20 ( 2 0 - 4 ) = 16
P5 ____
(it) And average wait and tumarou nd time
(53/5) = 106
Average
Soln. : The Gantt chart is,
P4 PC
| - | p t |p2|H>pi|pz|P3|P4|ro|P<|ral L ___ (ii) SJF( Preemtive)
o” 15 30 45 W re M 100 115 1 30 145 ISO 165 180 185 200 215
P1 P2 P3 P4 P5 Pi
PI ( 1 8 5 - 10) - 1 7 5 (15 - 10) + (60 - 30) + (130 - 75) + (180 - 145) PI 3 20 ( 2 0 - 0 ) = 20 (13-1)J
= 125
P2 1 2 (2-!)=l (1-lWJ
P2 (85- 10) = 75 (30 - 1 0 ) + (75 - 45) = 5 0
P3
bJ
2
II
5 (2-a i
1
Average (17/5) |
= 130 ms. (37/5) = 7.4
Average waiting time = (14Q +
- ■ JV t JU + /{jys
=
87 ms. r~m P4 P3
0 8
Scanned by CamScanner
System (MU - Sam 4 - I'
2-25 ____________Process Managsm t
Finish tin» r ' '
priority TAT Watting Unw
Ptocwm Proc+ca TAT Walting Uma 1
(& — 0) - B 0
P1 Pl (29-0) 29 (B ■ 2) + (11 - B) +{16 - 13) +{16 - 17) . 1 0 I
(9-i) -a (8-1}*7 PZ (iB-o)-ia (2 - 0 ) + ( 6 - 4 ) +{13 - 1 0 ) +(17 -15) = 1 1 I
12 ( 1 4 - 2 ) = 12 (11 - 2 ) = 9 P3 (ii - q . i t I (4-0) +(10-6) > B
14 (11-3) = 8 (9 - 3 ) = 6
P4 ] W3 ■ 18.13 1 29/3 =9.66
20 ( 2 0 - 4 ) = 16 (14 - 4 ) = 10
PS Example 2.17.10 MU -Dre. 2016. 1 0 Marks
(52/5) = 10.4 (32/5) = 6.4
Average Assume the following processes arrive tor execution at the
tune i n d i c a t e d and the length of epu burst time given in
Priority (Pr» P* lw> > .. msec.
(iv) P3 I P1
P4
PI P2 Job Burst time Priority Arrival time l
5 12 14 20
T
0 Pi __ 8 3 3
Finish time TAT Waiting time
Proc*®*
rtorfty Pa 1 1 I A
20 ( 1 2 - 0 ) = 12 (5-1)= 4 Ps 3 i 2 I ? |
3
PI
(2-1) = 1
P4 2 3 I 3
1 2 (1-1)= 0
P2 P5 6 4
|
r * I
■fS
!£>
co
II
1
5
m
it
l
0
P3 2 For the above process parameters, find average waiting
7 ( 1 4 - 3 ) = 11 (12-3) = 9 times and average turnaround times for the following
P4 3
scheduling algorithms. First Come First Serve, Shortest Job
4 13 (20 - 4 ) = 16 (14 - 4 ) = 10 First, non preemptive priority and Round Robin (assume
P5
quantum = 2 Units)
(43/5) = 0.6 (23/5) = 4.6
Average J _J Solution :
Example 2 J 7.9
FCFS (First Solution)
J _ _ _r S
processes with CPU burst time in ms. Assume that all
1 2 5 13 15 21
processes arrive at time 0.
I Job Priority Arrival Finish TAT Waiting time I
Time time
P4 3 3 15 I (15-3) = 12 (13=3) = 0 |
P1 P3 P2
P5 4 . 4 21 I (21-4) = 17 | (15-4) = 11 I
0 7 10 29
Average | (43/5) = 8.6 | (23/5) = 4.6 |
P3 2 2 5 I (5-2)=3 I (2-2)=0
Following is Gannt chart 3 3 7 (7-3)=4 (5-3) =2
P4
P1 4 (21-4)=17 | (15-4) =1
P2 P3 PI P2 P3 P1I | P2 | P1 | P2 | I P5 4
29 (37/5) = 7,4 ' (17/5) =3
13 15 17 18 Average I
0 2 4 6 8 10
Scanned by CamScanner
Process
24S
(S2)-3
(2-2) a 0
_ and RR (a u a n t u r n 2 ) t u
P3 2 2 5 (5-2) = 3 (2-2) = 0 P3 2 12 ( 1 2 - 2 ) = 1Q
P4 3 3 15 (15-3) = 12 (13-3) = 10 P4 2 14 ( 1 4 - 3 ) = 11
P5 4 21 (21-4) = 17 (15-4) = 11 P5 4 20 (20-4) = 16
Average (43/5) =8.6 Average
(23/5) = 4.6 (53/5) = 10.6 (33/5) = t6
Round Robin - quantum - 2 units
SJF (Preemtive)
Job Priority Arriwl Anieh TAT Waiting time
Time time i P2 P3 P4 _ P5 P1
PI
21 0 1 2 5 7 13 20
18 13) + (19-15) = 12
P2
2 (2-1) = 1 Proce.1 Priority
(M) 0 Finish time TAT
P3 2 WaNngta
1 (11*2) = 9
(2-2) + (104) = 6 Pl 3
P4 3 20
a (3-3) = 5
( 2 0 - 0 ) = 20 ( 1 3 - 1 ) = 12
(6-3) = 3
P5 P2 1
19 (19-4) (2-11= 1 (1-11=0
15 P3
Average 2
5
ro
1
ll
(48/5) (2-2)=0_
005) = 6 P4
9.6 3
7
P-3) = 4 (5 -3) = 2
P5
13
(13-4) = 9 (7-4).3_
Average
Scanned by CamScanner
system <MU-Sem 4 -IT>
2-27
Process Management
JjHN nP ' t ' Ve)
MU - N o y . 2015. 1 0 M a r k s
Consider following set of processes with their CPU burst
time.
_ _ _i
14 ___ ( 1 1 - 3 H 8
e
CO
<0
D r a w Gantt chart FCFS, SJF preemptive and round
II
3 J
20 ( 2 0 - 4 ) = 16 robin (quantum w 3), Calculate average waiting time
4 (14 - 4) = 10
Pfi_ _ and average turnaround time.
(52/5) = 104 (32/5) = 6.4
Avsmg® («> Explain which scheduling policy adopted by Linux?
Solution :
priority (Preempt)
Process TAT Walting time 1
2 P3 | P4 P5
r rp* I I
1
-------"T 2 5 12 14 20 Pl (23- 1) = 22 ' ( 1 4 - 2 ) = 12 \
1
0
P2 (6 - 2 ) = 4 0
Finish time TAT Waiting time I 1
Priority
Procs*
P3 | ( 1 4 - 3 ) = 11 1 (9-3) = 6 1
3 . 20 ( 1 2 - 0 ) = 12 (5 - 1 ) = 4
PI
VI
P4 1 (6-4) = 2 1
II
1
1 2 (2-1) = 1 (1-1)= 0
P2
Average 42/4=10.5 | 20/4 - 5 |
SL
CM
co
5
ii
II
1
P3 2
FCFS Scheduling
3 7 (14 - 3) = 11 (12 - 3 ) = 9
P4 _]
4 13 ( 2 0 - 4 ) = 16 ( 1 4 - 4 ) = 10
P5 [
P4 ( 2 3 - 4 ) = 19 (20-4)=_16 _ _ _
Waiting time
Praceu Priority Finish time TAT
Average 59/4=14.75 | 37/4=9.25
( 2 0 - 0 ) = 20 0+(9’2)+(14-1lH18-16) = 12
(H) SJF Preemptive Scheduling
(3-1)= 2 (2-0 = 1
7
(12- 2) = 10 (3-2M11-5) =
(7-3} = 4 (5-3) = 2
(18 - 4 ) = U
f P 1 I P9 I P3 I P 4 | Pi I P2 | P 3 | P1 I T U
Average 1 4 7 10 1 3 16 17 19 22 23
lives minimuia average waiting lieie.
Scanned by CamScanner
Operating System (MU • S errl *—S
pthread Scheduling
Waiting time
TAT Following are the pthread ““«““»■> value,
12 PTHREAD_SCOPE_PROCESS is u
(23- I )=22
(4- threads using PCS scheduling.
( 1 7 - 2 ) = 15
PTHREAD-SCOPEJSYSTEM is Used
(19- 3) = I 6 (7-
threads using SCS scheduling. to
(13-4) = 9 ( ro- 4) = 6
40/4= 10 PTHREAD_SCOPE„PROCESS to sched u
62/4 =15. 5
available light weight processes. Thread
Syllabus Topic : Thread Scheduling the number of LWPs. Scheduler activati Ons c
Windows XP, Solaris 9; and Linux use one-to-one In asymmetric multiprocessing, all sd
model and schedule threads using only system- decisions, I/O processing, and other system t
contention scope.
Scanned by CamScanner
2’29
Process Management
2.19.4 Multicore Processors
s
Some “PP° n a* affinity scheduling in
Which same thread again and again gets scheduled on days, it is possible to place multiple processor
cores on the same physical chip.
same CP U. Tins makes better use of previously cached
This is called multicore processor, Each of the cores is
blocks and increases the cache hits.
e
as separate physical processor by OS as there is
Also, the TLB may also have the right pag es , reducing
register in core to set its architectural state.
7L0 faults. For creation of affinity a two-level
SMP systems using multicore processors consume less
scheduling algorithm is used.
power and efficient.
After a ttread 1S
created, it is assigned to a lightly
j ded CPU which is a top level of the algorithm. It Scheduling is complex for multicore system. The
ensures that, each CPU acquires its own collection of processor accessing memory has to wait for data as it is
not available. So processor spends 50 % of its time in
threads*
waiting.
_ The bottom level of the algorithm performs real 4
- As a solution over this, hardware designer provided
scheduling- It is carried out by each CPU separately, on
two or many hardware threads for each core.
the basis of priorities or some other means.
If one thread has to wait for memory then core switch
_ By trying to keep a thread on the same CPU for its
to other thread. OS treats each hardware thread as
entire lifetime, cache affinity is maximized.
logical processor for S/W thread.
, In case if a CPU has no threads to run, it takes one from
- The course grained and fine grained multithreading can
another CPU instead of remaining idle.
be used to multithread a processor.
Approximately equal load distribution over the
Multithreaded multicore processor requires two level of
available CPUs, cache affinity and minimizing
scheduling. OS schedules software thread on hardware
contention for the ready lists as CPU frequently uses thread using any scheduling algorithm.
same ready list are three benefits offered by two-level
Second level of scheduling involves how each core
scheduling algorithm.
make a decision about which hardware thread to
Soft affinity means same process will be scheduled on execute.
same processor and keep running on it. This can be
policy but cannot be guaranteed by OS. 2.19.5 Virtualization and Scheduling
Process migration on other CPU may happen. In hard - With virtualization, single CPU system works Like
affinity process can not be migrated to other processor. multiprocessor system.
The virtualization software offers one or more virtual
2.19.3 Load Balancing
processors to each of the VMs running on the system
The main objective of load balancing in symmetric and then schedules the use of the real CPUs among the
multiprocessing systems (SMP) is to keep the load VMs. VMs are created and managed by host operating
balanced among all the processors. system. Each V M has guest OS and applications
running within it.
Load is evenly distributed among all processors.
Otherwise some processors may remain idle and other The guest OS scheduling algorithm that expects a
will be heavily loaded. convinced amount of progress in a given amount of
time will be negatively impacted by virtualization.
In push migration approach of load balancing, a
specific process periodically check load of processors. 2.19.6 Other Multiprocessor Scheduling
If it finds the processor with light load then it migrates Approaches
process from heavily loaded processor to lightly loaded
Following are the four general approaches used for
or idle processor.
scheduling of threads on multiprocessor system.
In pull migration approach, idle processor pu
waiting task from heavily loaded processor.
Scanned by CamScanner
2-30
T d harinfl approaches
TT on -ftrst-served (FCF$)
bef
7~ iiesTriu o f threads tirg
I r pmGanfl __ ~~
,J
Fig. C2.13 ° ad sharin
K “PProa ch(ai
fiR C Z U : Appn-chesnsed for scheduling of th"-* The threads of the newly arrived j ob
R
* C onmultlpnrcessor system consecutively at the end of shared q Ueue
processor selects next ready thread and cx '
(A) Load Sharing it finishes execution or gets blocked.
eue
single global qu
In this approach, load is equally distributed among all Preempted threads may not get same processal
the processors so that no one remains idle. resume execution. The caching becomes lessefficJ
There is no need of centralized scheduler The processors have cache memory.
scheduling routine of the operating system executes on It is unlikely to get access to a l l the threads J
available processor to choose the next thread.
program at the same t i m e . If more coordination
maintained global queue can be accessed by using equired between thread t h e n process switch may is
schemes used in uniprocessor scheduling such J to poor performance.
parallel there id
performance * more incltaii
Scanned by CamScanner
■rating System (MU - S e m 4 - 1
Process Management
Sch eduling overhead can be minimized as a sinele
decision affects a number of processors and procesLs
&h a set of nm-time library routines).
This approx may
Gang scnc . vh anon whose any be appropriate for some
applications and not for all. Applications can be
part is flOt * tfUJ,ng ant other 1S raad
y for execution. implemented to take advantage of this feature of
en,cnted in many ,nukl
lt i s ijnp' Processor operating operating system.
' systems- rn this scheduling process switches are Operating system is only responsible to processor
cd rcJatcd threads
ini ran in parallel. Hence, a ocatinn and performs following tasks when job demands
nnanceisgpod-
one or more processors.
threads that require coordination run in parallel, Allocate the idle processor to satisfy the request.
thcy can access file without additional overhead and
If job is new arrival and need processor then take the
source allocation can be done with less overhead.
processor from currently allocated job to which more
than one processor is allocated and allocate to newly
processors and M applications with N or fewer threads amved job.
are present then each application could be given 1/M of In case if jobs request cannot be satisfied then it
available time on the N processors, using time
slicing- or the job withdraws the request.
After release of one or more processors
In this approach, during execution of program the Search the queue of requests that are mot satisfied for
number of processors assigned is equal to number of processors. Allocate a single processor to each job in
threads available in program. the list that are waiting new arrivals and currently has
no processors.
All the processors returns to pool of processors after
program complete the execution. In this approach, if Then search the list again, allocating the remaining
processors on an FCFS basis.
thread of an application is blocked waiting for I/O or
for synchronization with other thread then processor
remains idle. It can be addressed as following : 2.20 Exam Pack
o If tens or hundreds of processors present in system
(University and Review Questions)
then processor utilization does not matter for
Syllabus Topic : Process Concept
performance,
Q. What do you mean by process ?
o As process switching i s avoided, it results in better
improvement in performance, (Refer section 2.2) (3 Marks) (Dec. 2014)
Q. Explain the concept of process,
2.19.6(D) Dynamic Scheduling
(Refer section 2.2)
- In some applications, the number of threads changes Q. What is context switch?
' during execution. (Refer section 2.3)
The operating system then can adjust the load to Syllabus Topic : Operation on Processes
improve performance. Both OS and application can What are the operations performed on
Q.
carry out scheduling task. process? (Refer section 2.4)
The operating system partitions the processors to Q. Explain process creation.
allocate to the jobs, (Refer section 2.4. 1)
■ The runnable task of each job is mapped to threads and Explain process termination
Q.
is given to the processors for execution at present in its (Refer section 2.4.2)
partition,
Q. Explain role of process control block.
A proper decision, about which subset to run, in (Refer section 2.5) (5 Marks) (Dec. 201 4)
addition to which thread to suspend when a process i_
Scanned by CamScanner
2 32
4
System (MU - Sem 'L Syllabus Topic : Process Sch T
Q. Explain process control blocn. Basic Concepts
Q.
Q. Explain SJF and SRTN sghe
(Refer section 2.8. 1(C))
Scanned by CamScanner
I CHAPTER
131
[ Module in
s Process Coordination
•'X
I
sp
\„
Syllabus Topics
— —J
9
X Synchronization : The critical Section P hi
X) 0 SSZss S-z
l6 Syllabus Topic ; Synchro n ization how the operating system handles interrupts, and the
% ,
scheduling policies of the operating system.
3,1 Background The difficulties that arise
1. Global resources sharing. For example, suppose two
(May 16)
processes use the same global variable simultaneously
Q. Explain the process synchronization in brief.
and both carry out read and write operations on that
MU - May 2016, 5 Marks
variable, then various reads and writes execution
In a single r proccssor multiprogramming system. ordering is serious.
2. Optimal management of the resources is not easy for
the appearance o f concurrent execution, a fixed time the operating system.
r'ng slot is allocated to each process. After utilization of this Programming error tracing is not easy as results arc
time slot, CPU gets allocated to other process. Such typically non- deterministic and not reproducible.
switching of C P U back and forth between processes is Only a single user is supported by single processor
called as context switch. multiprogramming system at a lime. While working on
At a lime single process gets executed so parallel one application, user can switch to other application in
tScJ
processing cannot be accomplished. Also there is a this system. The keyboard for input purpose and screen
ieti!. definite amount o f overhead drawn in switching back for output purpose used by each application is same.
The reason is, each application needs to use the
and forth between processes. Apart from above
The comparative
depends speed
on activities of execution
and behavior of process
of other P -s .
Scanned by CamScanner
3-2 , i f is necessary to use shared 8 . L
at a time.
among
. dose c by
0
processes, sharing Pn sequence :
I- initially process # a MU - Ma
getcharo returns its v stnugh »
chinput. Process Pi gc*® At Hus
xored in --Ration and communication
—XS “ Xi ents should be satisfied w
the mos‘ recenuj
q
variable chinput. o f process P 2 nnicate with each other. Synchr
passes is required to achieve the mutual
2.
it call up the ec on monitor. Independent processes do not comm unicate
situation, process P; is in suspended state and it is Processes can then exchange information by
still inside the echo procedure. The process P 2 is and writing data to the shared region.
not allowed to enter inside the echo() procedure.
In the message passing model, communication
Therefore, P 2 is suspended until P, comes out of
place by means of messages exchanged bet##11
the echo procedure.
cooperating processes.
Scanned by CamScanner
Operating System (MU - a . m
__ 3-3
- Follow, ng are the two primitives used in I Process Coordination
passing : * I Message passing system should give guarantee that
messages will be correctly received by receiver. Receiver
sends acknowledgement to sender after receiving the
message, if acknowledgement not received in defined time
This is the minimum two operations required for 1 en sender resend the message. It also offers authentication
processes to send and receive the messages. A process service.
sends data in the form of a message to another process 3.3 Race Condition
indicated by a destination. A process receives data by
executing the receive primitive, indicating the source , Q- What Is race condition? Explain with example.
and the message. A race condition takes place when more than one
Communication by sending and receiving messages process write data items so that the final result depends on
require synchronization. The receiver cannot receive a the order of execution of instructions in the multiple
message until it has been sent by another process. processes. Consider two processes, P $ and Pj, which share
the global variable “x”. At the time of execution, process P t
The sending process is blocked until the message is
updates x to the value 1 and at the time of execution of
received, or it is not after the send primitive executed
another process, P 2 updates “x” to the value 2. Thus, the two
by process. Similarly, when a process issues a receive tasks are in a race to write variable “x”. In this example the
process that modifies x value lastly decides the final value
o Previously sent message is received and execution of"x”.
continues. Role of Operating System
o If there is no waiting message, then either (a) the 1. The operating system should be capable of keeping
process is blocked until a message arrives, or track of the different processes.
(b) the process continues to execute, abandoning Allocation and reclamation of various resources should
the attempt to receive. be done by operating system.
Thus, both the sender and receiver can be blocking or Each process’s data and physical resources should be
nonblocking. Three combinations are common, protected by operating system against unintentional
interfering by other processes.
one or two combinations implemented : The operations performed by the process and the
O The blocking send and blocking receive : Until output that it generates should not depend on the speed
the message is handed over, the sender and of execution compare to the speed of other concurrent
receiver both gets blocked. processes.
is in need of message so that it can resume the The conflict occurs between the concurrently executing
execution . So it gets blocked until message
arrives. resource. More than one process may require the same
resource while they are executing. The existence of the
Nonblocking send, nonblocking receive :
particular process is not known to other process. The
Neither party is required to wait.
The nonblocking send and nonblocking receive: competing processes do not pass the information to each
other.
-
Both sender »'« " “
will continue the work.
Scanned by CamScanner
4
Tnoeratinq System (MU SgL- '
mating
--— ■ M U - Dc
nnrwri 2. Progress Wha
Q. Whi
Q. Explain cndca) -MU
— - June on 15 10 Blgi
solutions
ou Fig . C3-2 : Conditions of critical section At the
, it i5 necessary <o «"<' ' variable, al
i Mutual exclusion
lai the sar
some means to disallow more th® n,on of
I process h?
section (CS). K currently Process P 5 i a e
Synchronization statement
Scanned by CamScanner
irating System (MU » Sem 4 - IT) 3-5 Process Coordination
3,5 Mutual Exclusion Following 4 conditions should hold to obtain a excellent
solution for the critical section problem (mutual exclusion) :
(June 15, Nov, 15, May 16)
1. Two processes should not be inside their critical
q What is mutual exclusion ?
sections at the same time.
MU - J u n e 2U15- N o v 2015. 5 Rfia r k s
2. Comparative speeds of processes or number of CPUs
What is mutual exclusion ? Explain its
M U - M a y 2016, 5 M a r k s
in the systems are not assumed.
3. Process outside its critical section should not block
At the same time as one process executes the shared other processes.
variable, all remaining processes wishing to accomplish so 4. Any process should not wait for longer amount of time
a t the same instant should be kept waiting; when that arbitarily to enter its critical section.
process has over executing the shared variable, one of the
processes waiting to perform so should be permitted to cany Syllabus Topic : Petarson’s Solution
on . In this manner, each process executing the shared data
(variables) keep outs all others from doing so at the same 3.6 Peterson’s Solution
time. Only one process should be allowed to execute in
critical section. This is called Mutual Exclusion. Q. Explain Peterson solution to mutual exclusion.
Q. Give software approach for mutual exclusion.
The mutual exclusion is put into effect only if
processes access shared changeable data - If during Peterson's solution involves only two processes. It
execution, the operations of the processes do not conflict
gives a good means of algorithmic explanation of work
with each other, they should be permitted to proceed in out the critical-section problem and exemplifies some
parallel.
of the difficulties concerned in designing software that
<r Requirement of Mutual Exclusion addresses the requirements of mutual exclusion,
Scanned by CamScanner
_- - - Prt . 1
9 pi al entCr cri,ic
" " " — i then * ““ «?\l
’oporatiraSystemjMU; lfX
ft will enter the critical section.
•ratin'
fts critical section, it win res M
e
*’ owjng ft to enter its critical section j Following are
y fO = TRUE; *<r yv LU
t i l to tru ’ it 6
alsft must
MOVX
pj resets 1.
&& x== A ft does not change the value of A Return
while (ylfl
Considt
while executing the while statement.
Asquint
critical Berben Critical section (progress) after at most
(bounded waiting). So stq
execut
= SynchronSg , Pj gets
the Cl
_ Tbe bounded-warring requirement also achieved. any programming task easier and get to e
1. TSL ACC, X
t0 g t0 the critical section
(Content of X is copied to
m-ir-false,
W T P, can ° go
and “ j nto ils eritjcaj - 'y
Content of X becomes N)
has set y[j] to true and is also ninn - •
2. CMP ACC, “F*
(See if critical region is ft*1
3. BU 1
J (If critical region not
Depending on the value of x either P, „ F DJ - W l . 1*enter
~ in
‘
the critical section. back.)
4,
Return •iff)
Scanned by CamScanner
.rating System (MU - Sem 4 - IT) " 3-7 Process Coordination
Definition
MOV X, “F* (F gets copied to X) A semaphore S is integer variable whose value can be
Return (Return to caller) accessed and changed only by two operations wait
(P or sleep or down) and Signal (V or wakeup
or up). Wait and Signal are atomic operations.
Assume initially scheduler schedules Pi and X = "F*.
Binary Semaphores does not assume all the integer
So step 1 makes ACC= F and X= N . Here Pl after values. It assumes only two values 0 and 1. On the
executing step 4, prepare to enter CR (critical region).
contrary, counting semaphores (general semaphores)
can assume only nonnegative values.
the CR* Pj executes step 1 and X = N. In step 2, Pj fails The wait operation on semaphores S , written as wait(S)
the comparison and loop backs. It cannot execute step or P(S), operates as follows :
wait(S): IF S > 0 I
THEN S: = S — 1 I
Even though context switch occurs and Pj gets
_ _ _ _ _E15E (wait on S) ____ __________ ‘1
and X values are N (busy waiting). The signal operation on semaphore S , written as
to exit the CR ans X — **F . aignal(S): IF (one or more process are waiting on S)
If Pj scheduled after this, it execute step I and ACC
THEN (let one of these processes proceed)
becomes F as X was F in above step. Now due to step I
ELSE S: = S + 1
Scanned by CamScanner
for the producer
I".
process
, f l extP«»diiced;
« -ss£ ‘‘ jit 53
v rl
. n % ARRAY-SIZE;
Sete
For
counter •I' * .— ■—- ' “
Scanned by CamScanner
rating System (MU - Sem 4 - rp
3-9
consumer do not access modifiable shared section of Process Coordination
me buffer simultaneously. While defining the reader/ writers problem, it is
assumed that, many processes only read the file
Initialization
(readers) and many write to the file (writers). File is
- Set full buffer slots to 0. shared among a many number of processes. The
i.e. semaphore Full = 0.
- Set empty buffer slots to N.
to
i.e. semaphore empty = N . many readers.
Writing to the Hie is allowed to only one writer at
- For control access to critical section set mutex to I
the same time.
i.e. semaphore mutex = 1.
Readers are not allowed to read the file while
Producer ( ) writer are writing to the file,
WHILE (true) In this solution, the first reader accesses the fde by
produce-item ( ); performing a down operation on the semaphore file.
P (empty); Other readers only increment a counter, read count
P (mutex); When readers finish the reading, counter is
enter-item () decremented.
V (mutex) When last one ends by performing an up on the
V(fuil); semaphore, permitting a blocked writer, if there is one,
to write. Suppose that while a reader is reading file,
Consumer ( )
another reader comes along. Since having two readers
WHILE (true) at the same time is not a trouble, the second and later
P(fiill) readers can also be allowed if they come down.
P (mutex); After this assumes that a writer wants to perform write
remove-item ( ) ; on the file. The writer cannot be allowed to write the
V (mutex); file, since writers must have restricted access, so the
V (empty);
writer is suspended. The writer will suspended until no
reader is reading the file. If a new reader arrives
conaume-Item (Item)
continuously with very short interval and perform
Busy Waiting reading, the writer will never obtain the access of the
■> (Nov. 15, Dec. 16) file.
What do you mean by busy waiting? What is To stop this circumstance, the program is written in a
wrong with it ? different way: when a reader comes and at the same
M U - N o v . 2015, Dec, 2016, 5 Marks time a writer is waiting, the reader is suspended instead
of being allowed reading immediately.
Now writer will wait for readers that were reading and
If critical section is not free (process is already executing in
about to finish but does not have to wait for readers that
it) then other process trying to enter in critical section
came along after it. The drawback of this solution is
that it achieves less concurrency and thus lower
(continual looping) is the problem as far as performance. Following is the solution given
multiprogramming environment is considered. In this case a
single CPU is shared among many processes. This busy typedef int semaphore;
waiting waste CPU cycles which would have been used by semaphore mutex = 1 * controls access to ’readcount’*/
other processed effectively. semaphore file = 1;/* controls access to file ♦/
void reader(void)
Q. Explain reader-writer problem.
Scanned by CamScanner
Pl
3-10
, . .u’reudeount’*/
up{*ntu<«)y* rrleiue e x c l u d e acces
The dini n 8 philosopher’s problem c ’
r»d fik()/*nMd the file*/
example of problems related to
downW) exclusive to ' coun resources, which may occur whei)
upfOrmutextV release
r <t[]ri
Scanned by CamScanner
11 - S e m 4 . ft-)
V ,
i ii - - [ _Proc&ss Coordination
If «maphnre S flTC uwd incorrectly, k efln pnjducc
parbe n (philosopher (0), philosopher ( 1 ) ,
>*»ning e ™ that arc hard to detect. These errors occur
philosopher (2), philosopher (3), only ( f some pabular execution sequences results and
philosopher (4));
icsc sequences do not always occur. In order to handle
*> i such errors, researchers have developed high-level
p 0 language constructs called as monitor.
A monitor is a set of procedures, variables, and data
four philosophers at a time into the dining room. With structures that arc all grouped together in a particular
‘V
at most four seated philosophers, at least one type of module or package. Processes may call the
Scanned by CamScanner
3-12
Volatile storage
again the monitor when the condition alters, and
resume execution at the point in its program following Examples are main memory or cache memory |
the cwait (x) call. system crash, information on this storage
Scanned by CamScanner
gwrating S stemJM -_Sgn 4 - I T ) 3
Process Coordination
o New value : Value of data operation after write
executed atomically. A serial schedule contains a
operation is carried out.
sequence of instructions from different transactions in
Other log records are also there to record the significant which the instructions of a particular transaction appear
events during processing of the transactions. These are together.
for example, start of transaction, commit or abort of If two transactions overlap their execution then the
transactions. Using these logs the data is easily resultant schedule is no longer serial. A nonserial
recovered in case of failures. Recovery algorithm uses schedule does not essentially mean an incorrect
following two procedures: execution. The Fig, 3.1 1. 1 shows the serial schedule in
o undo(Ti) : The data items updated by transaction which TO is followed by T L The Fig. 3.1 f .2 shows the
Ti is restored to old value by undo(Ti) procedure. concurrent serializable schedule.
o rtdofTi) : This procedure set the value of data
TO T1
items to new value. These data items are updated
READ(X)
by transaction Ti. WRIT (X)
READ(Y)
3.11.3 Checkpoints WRITE(Y)
READ(X)
Searching of log is carried out in case of failure. It is WRITE(X)
READ(Y)
necessary to search the log to know the transactions to be WRITE(Y)
redone and undone after failure. This searching is time
consuming and modifications on updated data will cause Fig. 3.11.1
recovery to get longer. Checkpointing is the solution over
- Fig. 3.11.1 shows that serial schedule in which TO is
this problem. Along with maintaining the write-ahead log, followed by T k
system time to time takes checkpoints which involve the
following sequence of actions to take place : TO T1
- Write all log records at present residing in main READ(X)
memory onto stable storage. WRITE(X)
READ(X)
Write all modified data residing in volatile storage to WRITE(X)
READ(Y)
the stable storage. WRfTE(Y)
READ(Y)
- Write a log record <checkpoint> onto stable storage. WRITE(Y)
As <checkpoint> record is present in the log, it permits
the system to make its recovery procedure more efficient. Fig. 3.11.2: A concurrent serializable schedule
3.11.4 Concurrent Atomic T ransactions Let OP 0 and OP ( are the two operations from
transactions TO and T I respectively. If OP 0 and OP> accesses
Each transaction is atomic. There can be many the same data item and at least one of the operation is write
transactions executing concurrently. This concurrent then OP 0 and O P t conflicts.
execution is equivalent to serial executions of the
transactions in any of the order. This is called as 3.11.4(B) Locking Protocol
serializability property. This property can be maintained by q. Explain two-phase locking protocol.
just executing each transaction within a critical section.
— A lock is associated with each data item to ensure the
3.11.4(A) Serializability serializability. In this case it is necessary by each
transaction to follow the locking protocol that defines
| Q, Write note on Serializability I
how locks are acquired and released. Following two
Let X and Y are two data items that can be read and models can be used.
written by two transactions TO and TI. Both o Shared. If a transaction Ti has acquired a shared
transactions executes atomically in - the . order mode lock on data item A, then T i can read this
followed by T I . This sequence of execution is called as item but cannot write A.
schedule. In serial schedule each transaction is
Scanned by CamScanner
Pl
In above two-phase locking protocol, the order We know that processes needs different resources!
followed by pairs of conflicting transactions is decided order to complete the execution. So in a multiprograra
at execution time. Other method selects the order in environment, many processes may compete for a multy
number of resources. In a system, resources are finite.S
with finite number of resources, it is not possible to Hi
uraenng scheme i s used. System
the resource request of all processes.
assigns a unique fined timestamp to each transaction
ore tt starts the execution. If TO transaction has When a process requests a resource and if the resori
T S(TO) and later T1
IS
system having timestamp TS(Th th t
” Ot available
at that time, the process enters a
a multiprogramming environment it
appen with many processes. There is chance**
W ting Processes
will remain in same state
nev
er again change state.
because the resources have
SyStem U the
tansactions occur on sepa -
for
Processor, not sharing a L t “
f en
will not work. method system then °f resources
avail *
C there 5
resource type instances
Scanned by CamScanner
Operating System (MU - Sem 4 - IT) 3-15 Process Coordination
Scanned by CamScanner
cycle can be broken. He,
Conserve y c ■
MU'
in
«** deadlock state. In case if cy cle K
. of all the active pre—
The set consisung
.riT. B ofalIresourcerypes
The set consisting Rnl
R
= 1 R
'■ tb d-rechon fro* 3.14
peadfockf!?*®
wi
8
h I f there is p .hen it mean
_ m this graph If typ e R n(jW
Q. MU - June 20i c;
Scanned by CamScanner
Process Coordination
not hold any other resource. Following two - The process which requests the resources should
protocols can be used. wait in case If resources are neither available nor
Allocate all the resources needed by process held by waiting process. In this situation, if other
before it starts the execution. This protocol will process make a request for the resource held by
keep the allocated resources unused. The reason is waiting process, then it should be preempted from
that, even though some of the resources are waiting process.
needed by process in the last stage of execution, it 4. Circular waft
will hold it from start of execution.
To prevent the occurring of circular-wait condition
Second protocol allows the process to request the inflict a total ordering of all resource types. In this
resources only when it has released the previously case each process should request the resources in
allocated resources. Again the disadvantage of an increasing order of assigned numbers to the
first protocol appears here. Suppose the important resources.
resource for which many processes compete is
Consider the collection of resource types R = {RI ,
needed only at the start and end of the execution
R2, ..., Rn). To this each resource type, a unique
by this process. If initially process release resource integer number is assigned. As resources are now
and at the end request for the same, then it may recognized by their numbers, it is easy to compare
not possible to get the same resource immediately. them. It is also easy to know if one resource
So we must request all resources at the beginning. precedes the other in our ordering. Assignment of
Apart from the limitation of the above two numbers to resources is a one-to-one function
protocols, other limitation can be starvation. In p ; r _+ N, where N is the set of natural numbers.
this, processes will keep significant and popular In order to prevent the deadlock, following two
resources with them forcing to wait other protocols can be used.
processes indefinitely which require these o Each process requests resources in an
resources. increasing order of assigned numbers to the
3, No Preemption resources.
o Whenever process request instance of
We have to ensure that no preemption condition
resource type Rj it should release any
does not hold. Following two protocols can be
resource Ri such that F(Ri) > = F(Rj) .
used.
— If a process at present keep some resources with it If these two protocols used, circular wait condition
cannot hold. If process P, waits for resource Ri which is held
and requests another resource that cannot be
by process Pi+I we get F(Ri) < F(Ri+l) for all i. It implies
immediately allocated to it, then all resources at
that F(R0) < F(R1) <F(R2) < ...... F(Rn) < F(RO). By
present being held should be preempted.
transitive relation, we get contradictory statement F(R0) <
The list of the resources for which process is
F(R0). circular wait does not hold
waiting is maintained. The preempted resources
from the process are included in this list. The " ""s nTbusTopicTpeadlockAvoidan ~
process now restart the execution provided that it
can get back its old preempted resources, in 3 d 5 Deadlock Avoidance
addition to the new ones that it is requesting.
(June 15, Nov. 15)
- If the needed resources by the process are
available, then allocate to the process requesting Q. Explain deadlock avoidance.
MU • June 2015. 2 Marks
for it. On the other hand i f they are not available,
then check whether it is allocated to the process What is difference between deadlock avoidance
and deadlock prevention? _____________
which i s further waiting for additional resources.
MU - Nov. 2015. 1 0 Marks
If it is the case then withdraw the resources from
waiting process and allot them to requesting
process.
Scanned by CamScanner
3-18 | -----
MU - Sam 4 -J
cr Example
with 10 disk drjy
Consider a
UU<MW«t>'* up
Maximum needs pollcwii
AvUres the nw'htwm number of resources nee
8
PO
An ltZn«»>« method for avoiding deadlocks is
4
require additional information about wjl| Pl
to be requested. I f the sequence in which pr« 7
P2
request the resource and will release it toow
Jk.on.Hy, then we can decide for each reque. \~il71O disk drives are available in
whether or not the process should wait. L 4PJ. P0. P2> is safe seq ueoce M
To avoid the circular wait condition completely, a ’'‘’“fres 8 disk drives, process P l requi 'M
deadlock-avoidance algorithm inspects the resour “ P2 may utre up to 7 disk 4
4
allocation slate in dynamic way. Following are ieTs PO «
holding 2 disk drives and prtrcess PO J
factors which define and describe resource allocation
state. drives. (Thus in the system 2 disk dnves
o The number of available resources in the system. At time to, the system is in safe state. 1 If
o The number of allocated resources in the system. <pi PO, P2> satisfies safety condition,*! if
o The maximum demands of the processes. immediately be allocated its disk drives 1
ii
Dijkstra's Banker's algorithm is used for deadlock them after completion. Now total 4 disk J
available. 1
number of resources each process needs. PO gets all the disk drives. After completion
- After that, the OS act like a sincere small-town banker. them and now total 8 disk drives are avails !
OS will allocate the resources to processes only it has system. Finally P2 can be allocated all the ne J
sufficient number of resources available to fulfill drives and returns them after completion. (The J
possible demand. This is considered as a safe state. will have now all 10 disk drives aJ
Safe State Fig. 3.15.1 shows safe, unsafe and deadlock
spaces.
- If the system is able to allocate resources to each
process up to its maximum need in some order and still
avoid a deadlock then the system is in safe state. Unsafe
If the system is a
e 5-1 Deadlock
deadlock. If the systein there can no Avoidance Algorithm#
ssib unsafe
P° ®y of dead]ock “ state, there is the
n (May ifc*
Scanned by CamScanner
Operating System MU - Sem 4 - IT) 3-19 Process Coordination
Scanned by CamScanner
JSToperating System (MU - Sem 4 - IT) 3-20
Maximum
Let R[n][ml be the two dimensional array, describe the uirenwnt)
CfAlK***"”
current outstanding requests of all processes. R[i][j] ~
indicates process Pi want k instances of resource type msw®®6
tyP Q ’ !
Rj. to accomplish the execution. 1
5, 2 , 2 , v ,ilabl'
3. 0.
1 .■ P0 So
H R[i][j] <= N[i](j], to step 2; otherwise, raise a® 1
3, 2, £ 3. 0 . 1
error condition as process is requesting mor 0, 2, that reC
P1 3, 2, 2 2 a- 2 resotirc 1
resources than it needs. 2. 0. <1 e1
wheth
P2
L If R[i](j] > A(jL then the process should wait as exists. I
2, 1 , 0
needed resources are not available. P3 5, 0. 3
0, 2
J, Otherwise, go to step 4 P4
The st®1® „ currently with sequence <pj
E*®r
4, Allocate the requested resources t< The 9yS
*‘ state- The sequence <P2, Pl ,
Corn
is altered as
A|jl = Aoi-mn satisfy the
sP2:
C[il[j] = C[ilO) + pO
’" ( | 2. 2 ) < = ( ' • 6 , 2 )
N(ilU) - N[i]lj] - R 1’1W - if the N<=
\ ( i , 6. 2 ) - < l . 2 . 2 ) = (0, M
4 Once the resources are allocated. **. wait
must A = A
~ C (0. 4. 0) + < 3 - 2. 2) =13,
system state is safe. If unsafe, the —
L the old resource-allocated states restored
:
process Pl
fe N <= A 1( 3 0, D < = ( 3 . 6, 2) is tree I V
This algorithm find out whether system is ■"
’ 6 > 2) _ ( 3 , 0. D = (0,6,1)
or not. A =A-N(3
1. U , w be an integer array of length m, ’ ( 0 , 6 , l ) + (3. 2, 2) = (3,8,
to available in the system after P l finishes.
be array A (Available
a boolean array of number
length n.ofinitialled
resource
Scanned by CamScanner
jgf Operating System (MU - Sem 4 - IT) 3-21 Process Coordination
jnstsnce of resource type P and two instances of resource (c) Yes, request can be granted immediately* After
type Q, so Request R2 - ( 1 , 2, 0) and it is not greater than granting this, Avaflabte will become ( l t 1, 0, 0).One of
available resources A. the safe sequence is (P0, P2, P3, P l , and P4).
So step 4 of the resource request algorithm indicates Allocation for P l becomes ( l t 4, 2, 0) and Need for P l
that request can be allocated. After allocation of these becomes (0, 3 , 3, 0),
sources, now safety algorithm is executed to determine Example 3.16,2
whether system remains in safe state. If any such sequence
Consider the following snapshot of the system.
exists, then system will be in safe state.
Process Allocation Maximum Requirement
3 16 Solved Problems A B C A B C
Solution :
(a) Need matrix is, ____________
- 1
Need
A B C D
(ii) A = 7, B = 3 a n d C = 6 are total instances of resources.
P0 0 0 0 0
By adding the Columns of Allocation matrix
Pl 0 7 5 0 We get, A = 4 , B = 3 and C = 5,
(b) System is in safe state because many safe sequences By using above available number of resources and
exist such as (TO; P2; P l ; P3; P4)- As avadab'e tt, < 1 . 5 . applying bankers algorithm, sequence
2. 0). either process P0 or « can complete the <P2, P3, P4t PO, P l > is safe sequence.
execution. Once process P3 finishes, tt release °
Hence, system is in safe state.
resources which permit all other existing processe.
execute.
Scanned by CamScanner
Max
R1 R2 R3
Ri
3 3 6 b Operator
t0 p4 2 2
pO P1 3 4 3 3
2 0
P2 3 4
Consider the An rthe
2
B c P3
0 c
0 0 current allocation a sate atete?
19
0 0 i) CU
request be flT *
o IIt h1°
0 M
0 1 0 ill wou
* (lU) The 5
P0 0 2
0
2 stat®7 , finist
2 0
P1 0 0 * P 1 requ®5 ' (1
’
0
0 3 Exampte
3 0
P2 1 0 on 2 3
Sotut* ncecPh? ’** * Conside
2 1
P3 0 2
0 0)
0 2 “: d
:,x— is
-
0
P4 instar** 5
caUon column
adding AH° ’
ABC be MaxlPU
RequesUPU = ' "'““Wil
NoW available in system are ( 7 , 7 . 10)
3
Example -1 6 5
I «>..« 101
Consider follow* An;
.yto P0, Let the P2 request for resources. Using Banker’s algorithm answer the following (a)
Scanned by CamScanner
Operating System (MU - Ssm 4 . n")
3-23
Process Coordination
A B C D
PO 2 0 1 1 M U - N o v . 2 0 1 5 . 1 0 M a i ks
Pl- 0 6 5 0 Consider the snap of the system.
P2 I 1 0 2 Process Allocation Max Available
P3 1 0 2 0
P4 1 4 4 4
ABCD abcd | ABCD
P0 0212 0322 2532
(jii) The system is in a safe state as the processes can be
finished in the sequence PO, P2, P4, PI and P3, P1 1102 2752
CM
•
(iii) If a request from process PI arrives for (1 .3,2,1) can
Pt *2 0 0 3 2 2
the request be granted immediately ?
CM
o
cv
o
ft
Solution :
Solution :
(ii) Yes, System is safe and safe sequence (PO, P2, P l ,
(a) Need = Max- Allocation P4, P3) exist.
(iii) As (3, 3, 4, 8 ) remains available in system, P l can be
granted (1,3,2,1) immediately
PO
Sylhbus°Top7c : Deadlock Detection
Pl
P3
Scanned by CamScanner
3-24 sSf=s=S=S
7\ c the two dimensional
Ssrn 4 - RI
“’ C req
““‘’ °f
r«=l. svstetnWii ,em cofte want k
Apr /npurgtrngj nrocess Pi 'Stances JpJ
or n 0t
:un«* . iishtheexecutioQ
r «m p ' s
Syl
deadlock i Ajfiorlth - -- ------
the o1 peadlocK Detecgj
3-1®!
J It n
which « e "* tunJ ... manure* W® Se'
I b ocess finishcd ot not)
w- Single instant* nf « of a wai ,.for (£ X» " lltii tha
t ,en to i
_ *•*»***!* graph. Wait for For all i , i f <*] ’= *
Ur
F[iJ = tr“ e -
F ind an i such that both Tli
frc
F[i] = false // Pi « currently
tv.
deadlock
allocation graph y e(Jges This is ju
W w
R(i]<=
«*““ l allLtion graph Fig- “ o
shown in resource w rj which If no such i exists, go to step 4
MDuree
shows that, process r p
// reclaim the resources of process Pi
is held by process P2. true; Go to ste 3.18
W = W + C(iJ; FM = P2
Pi
r2 If F[i] = false for some i,
Process ’caused’ .
Scanned by CamScanner
ggT Operating System ( M U - Sem 4 - IT)
3*25
Process Coordination
Syllabus T o p i c : Recovery from Deadl ~
Invocation of the detection algorithm after killing each
process is considerable overhead. We must re-run
algorithm after each kill.
Killing a process is not easy. We should kill only those
processes whose killing will incur minimum cost.
It needs to recover from deadlock when it is detected. Different parameters that need to be consider to ensure
Several options exist after detection algorithm detects the minimum cost arc :
that a deadlock exists in the system. One possibility is
o Priority of the process.
to inform operator and let them decide how to deal with
o How much computation process has finished and
ft manually.
how much more time does it need to finish the
The second option is to allow the system to recover execution.
from the deadlock on its own (automatically). There are
o The number of the resources process has used.
two solutions exist to break a deadlock. One solution is
o The type of resources the process has used.
just to abort one or more processes so that circular wait
will be broken. The second option includes preemption o The number of the resources the process will need
of some of the resources from one or more of the to complete the execution.
processes which are involved in deadlock. o The number of processes needs to be killed.
o Whether the process is interactive or batch.
3,1 8 J Process Termination (Kill a process)
3.18.2 Resource Preemption
When deadlock occurs, the operating system decides to
kill one or more processes. This will reclaim the resources Incrementally preempt the resources from the process
acquired by that killed processes. The deadlock detection and reallocate resources to other processes until the circular
algorithm detects whether deadlock exist or not after killing wait is broken. ________________________
the process. Following two methods are used for killing the Resource Preemption I
process :
u. 1 . Selecting a victim
Two methods used for
killing the process
M 2. Rollback
Fig. C3.5 : Two methods used for killing process 1. Selecting a victim
Which process and which resources should be selected
-Fl. Kill all deadlocked processes
for preemption to minimize the cost? The process
- This method is simple and effective to eliminate the which has finished almost all computation and only
deadlock and clearly will break the deadlock cycle, but few amount of computation is remained should not be
at a huge cost. selected as a victim.
- If all these killed processes have been performed die 2, Rollback
computation for longer period of time, then the part y
After preempting the resources from the particular
computed result would be wasted. Recomputation will
process, it cannot continue the execution as needed
be done and is veiy costly.
resources are preempted. It is required to rollback the
2. Kill one process at a time
time and process to safe state and restarts the execution from
In this method, one process i s killed whether that state. As safe state is difficult to define, total
detection algorithm is in v ° e t0
rollback will be the simple solution. _____________
deadlock is still exist or not in die system
Scanned by CamScanner
3 2
flfTI
r <DeCJ0 1
svHabutToP ’ ’\
Explain 0Wn9 philosopher
Q. 5 Q.
SIES * semaphores. (Refer sectron 3.9.4) *1
. Toole : Monitors
I j Syllabus Topi
Q.
with example- YYtrat is monitor? How it is used to ach .
„ . — — «“ Q.
exclusion? Explain. (Refer section 3. l0) >
Explain critical section probl (Dec. 2014) What is atomic transactions? Explain.
Q,
a (Refer section 3,11)
(Rg fer section 3.4) (5 Marks)
intri With its different
a. Q.
(Refer section 3.11. 4(A))
What is mutual exclusion?
a. a. Explain two-phase locking protocol.
<»*-*“ 3.9(5
(Refer section 3.5) (5 Martis) (May 201 6) a. What is deadlock ? (Refer section 3.
Syllabus Topic : Peterson’s Solution (June 2015, Nov. 2015, May 2016,Dec.?
° WhatBsemaphorelflefersectionS
Explain deadlock prevention.
*■ Syllabus Topic ; Classic Prnh teffl . of
0 ems (Refer section 3. 14) (2 Marks) (June*
Synchronization of
Q. * Explain an algorithm for ,„ What is difference between deadlock avoids
arorll
deadlock prevention?
Q. Explain how Realtor r section 3.14) (WMarks) (W*
, ,bU,T
, " O«k»k »«*!.«.
1 Ew a
“" ~<ta.»ad.„c..
__ n«20l5)
(Refer . ..
Scanned by CamScanner
gT Operating i System(MU - Sem 4 - IT) 3-27 Process Coordination
Scanned by CamScanner
Module iv
CHAPTER
Memory Management
““""X St
Memory, Other Considerations. - ----------------
0, e inmemory for other processes.
Scanned by CamScanner
Operating System (MU - Sem 4 - IT)
4-2 Memory Man agement
- If user designs the program which uses many library Symbol table and common routines are required in both
routines then operating system will itself support for passes. Consider the memory requirement of pass 1
dynamic loading. No special support require from module, pass 2 module, symbol table and common
operating system. routines.
Scanned by CamScanner
Memory Ma n
4*3
.Minn System (MU allocat
O
and logical adtte of i ogical 4
in o f ‘
Once overlay A finishes execution, overlay address JP®* a physical address J*'
requir
generated ny correspond ’
0VM lay B.B Overlay
overlay in pace of
B requires IM K o . sto g
collection ot an k r
jf we
the8el 1 f instruct ons d to after
4.1.5 Relocation _______— — — - 1 °bmdirtg » ’ “ "tens.1
swap
- Xe t at rfe time or load
a —
- ---------------------- Turnon
-------------------
as follows.
a
rX.cal addresses art same. If the same blrw
Consider the pactions of m e > « W _ «curs at run time then logical and physreal add It if
effec
100K (Operating system) are different. • » x I
First partition-
Second partition: 100K ™ location register (base register) contains
- IX) Physical address (5200) can be calcul * if sc
Third partition: 20dK prio’
Zws. Consider logical address 200 of
Founh partition: 300K * disk
program.
Consider veiy first instn ‘“ " fci file created by Aft £
Physical address (5200) = logical address (offtet) 1
absolute address 100 within the binary + content of base register (5000)
mat
Manning from virtual to physical addresses is dorei,
UlXioads the program in first partition at address Sw
the memory management unit (MMU) at nin time. Th
KJOK. then instruction will find OS at absolute address dat
user program deals with logical addresses. Tbt
100. cat
memory-mapping hardware converts logical address
If instead of first partition, loader loads the program in foi
second partition, the instruction will jump to address Th
Memory protection is done by using two registers,
100K+100. mi
usually a base and a limit, as shown in Fig. 4.1.2. The
For third partition instruction will jump to address base register holds the smallest legal physical memory T1
200K+100 and so on. This problem is called as address (in our example 5000). The limit register gives pf
relocation problem. the size of the range of physical addresses. For I
The solution to this problem is to in fact modify the example, if the base register holds 5000 and the limit I b;
instructions as the loading of program is done in register is 1000, then the program can legally access all I
memory. addresses from 5000 through 6000. I
il
If programs are loaded in first partition then 100K is r
added to each address, programs loaded into second t
1000
have 200K added to addresses, and so on.
]
To carry out relocation at the time of loading like this, 2000
Scanned by CamScanner
■stem (MU - Sem 4 - IT)
4-4
time sharing operating system, system's Memory Management
ln a
memory is
located to multiple processes. n this scheme memory is divided into a number of
storage (disk). The number of partitions and its size would be defined
If we use round robin CPU scheduling algorithm then by the system administrator when the system starts up.
after expire of time quantum memory manager will The degree of multiprogramming will be high if the
swaps out the finished process and swaps in the another number of partitions created is more.
pfOCCSS. Always a selected process from the input queue is
ft increases degree of multiprogramming ensures placed into the free partition. When the executing
effective management of memory among many process finishes the execution and terminates, the
processes. partition becomes free for another process.
If scheduling is priority based, then after arrival of high The operating system maintain a table to keeps track on
priority process low priority process is swapped out on free and occupied partitions by processes.
disk. Partitions can be of fixed size or of variable size. Fixed
_ After completion of high priority process again a low sized partitions are relatively simple to implement. The
priority process gets swapped in memory by memory problems with the fixed size partitions are :
manager.
I f program size is larger than the partition size, program
. Swapping needs a b a c k i n g store to store a swapped cannot be stored in partition.
data. The backing store is usually a fast disk and having
The second problem is internal fragmentation. If
capacity enough to store copies o f a l l memory images
partition size is larger than program size, some space of
for all users.
the partition will be unused within that partition.
■ This backing store must offer direct access to these Fig. 4,2.1 shows fixed size partitions.
memory images.
Size = 8 M
The operating system maintains a ready queue for the
0
processes which are ready to execute.
7
These processes h a v e their memory images on the 15
backing store or i n memory. 23
The CPU scheduler c a l l s the dispatcher program, when 31 OS
Topic : Cnrti-unua Memory Allocation It means smallest partition big enough to accommodate
the process is chosen,
__Contiguous Memory Allocation A queue is organized for each size of the partition
where processes wait for that partition.
Partitions are allocated to the processes with best-fit
Partitions i ______ fil 0
policy Best P ensures to allocate the partition
piain memory management with Fixed
0 Repartitions, exter nal Therefore variable partitions minimize internal
M
' '« is internal fragmentation an fragmentation-
J J ntation? Explain with example ___— -------
Scanned by CamScanner
Memory M an
4'5
Intern* 1 External
rating System ( M U - Sem 4 JT) parameter
reduce the Sr.
allocation may No.
However, such an aliocauv Paging
would quei* up Drawback Contiguous
performance as processes would queue up segmentation
memory
allocation reduce technique
tht
the internal solution
a queue of partition of size 8 , fragmentation externa]
fragmentation
problem.
are w
"“ 8 “ 2 Shows variable si«
external fragment!
' partitions.
0 In this technique basically a variable partitioning ,
Size ■ 1M
1 variable number of partitions determined dynamical!,.
Size = 2M
3
Size - 4M
7 is considered as one large block, of available menm,,
Size - flM
15 a hole.
OS
When a process arrives and needs memory, it search
Fig. 4.2.2 : Variable size partitions for a hole large enough to fit for this process.
This technique ensures the efficient use of main
Difference between Internal fragmentation a n d memory. There is no internal fragmentation.
external fragmentation
However, if the many small holes are scattered, it can’t
Q. Compare internal and external fragmentation. ] be allocated to one large size process. Consider the
Scanned by CamScanner
MU
fagg* j Sem 4 - IT)
4-6
cannot be allocated to the
P ess O f Jarger Memory Management
these holes. This is CaJJed
tion. extern niOve
one 1- g size hole of 8 MB at the dstart
downward, we get
of user memory
bm O S size = BM
OS
- 8M
ever in this, 48 MB processes need to be moved
compared to 28 MB shown in Fig. 4.2.4(b).
PI size - 22M t 4.2.4(d) shows the 28 MB shifting of processes.
P1
size =□ 22M
mpaction should ensure the moving of processes
av
ibg minimum total size. Compaction increases the
degree of multiprogramming.
P2 size = 20m It is because processes can be loaded in the memory
Size - 34M
which is available by combining many scattered holes.
If relocation is done at compile time (static),
S i z » = 14M compaction is not possible.
I l is possible only i f relocation is dynamic and done at
(t»
<«)
execution time.
OEJsza . SM O £ s u a = : BU
OS size - 8M OS size = 8M
P4 SC*- 1BM
Size = 2M P4 size - 18M
P4»ize= ISM
T ?M
P3 sue = TOM
P4 size - 1 8M P4 size k 18M
PIsizs ZOM P3rtz»- 1DM
PS sue . 10M
Si«- 8M
Size = 4 M ~
Size - 2M Size- 2M
(d)
!•)
P3 $ i z e = 1 0 M P3size = lOM
Size* TOM
Fig. 4,2.4 : Compaction
Size = 4M
Si»= 4M Size = 4 M
(O
4.2.4 Memory Allocation Strategies
-> (May 201 6)
Fig. W : Creation of scattered holes in dynamic
q. Discuss partition selection algorithm in brief.
partition technique (MU ~ May 2016, 4 Maries)
« the end of memory as shown in Fig- Fig. C4.1 = Memory allocation strategies
Scanned by CamScanner
Memory M.
4-7
MU - Sem W‘>rs,fit 600 K partition.
*
,12 K is pi* “> 600 . .
500KPartl
' L7K 1 s PU t*
* tototXltegyof mcoX Kparti,iOT(6ooK 2i2K)
: ; 1 2Kispu.to - -
wait
426 K must ' sout bethelit5t
- in e i e. B «t-mto2 l
available to start the search when!
H U - May
. Searching can either start of d-e set
previously search was s 1S big
oTselection algorithm in brief. Given
d18CO6S parton ZQOk 300k and 550k (In orte r) ,
of holes.to hold
enough Searching end *is local
the process
parttfc>n
° h «f the W fit. beat fit and worst lit algorithm
220k, 430k, 110k , 425k (in order),
*lx* X'ZXkes
Solution :
the moat effident use of memory?
First-fit
2 2O K is put m 500 K partition.
<+
—
3, Worst-fit
— ] 10 K is pul in 150 k partition.
_ b strategy of meminy
largest bote gets allocated to incoming process. Ag .
, If the list of botes is not kept i n sorted order of size Best-fit
then the complete list needs to be searched Tins
approach leads to create the largest leftover hole which
can be used again to allocate the next incoming
process _______
Example 4.2.1
Worst-fit
Given memory partition of 1 00 K, 500 K, 200 K, 300 K, and
600 K in order, How would each of the First-fit, Best-fit and
Worst-fit algorithms place the processes of 212 K, 417 K,
430 K is put in 500 K partition.
112 K and 426 K in order? Which algorithm makes the most
efficient use of memory?
1 10 K is put i n 330 K partition (550 K - 220 K).
Best-fit
Whaf is paging? M U - J u n e 2015. 5
- 212 K is put in 300 K partition.
Paging i s memory management technique which
- 417 K is put in 500 K partition.
Physical address space of the process *
- 112 K is put in 200 K partition.
noncontiguous.
- 426 K is pot in 600 K partition.
SCnsc
nr ’ pa 8 in 8 mechanism is similar to .
a book. When we read a book we only see
open the cunent toread
Scanned by CamScanner
(MU - Sem 4 - JT)
4-8
other pa.es are not le to Us
Memory Management
do**1
WS
tbe san* manner, we can say even logical memo model of physical and
We
' L have a large program available, the orn „ Rowing basic operations is done in paging : ’
g a s m a n set of instructions to execute at
aH these instructions which the processor needs two d *° cal address and it is divided into
Page number (p) and a page offset (d).
' pjiecute are within a small proximity of each other
Pafie numbe
* r is used as an index into a page table.
>s is like a page which contains all the statements base address of each page in physical memory is
whic h W e are currently reading.
maintained by pa ge table.
in this way paging allows to keep just the parts of g
Jhe combination of base address with page offset
process that we re using in memory and the rest on the mes the physical memory address that is sent to the
disk. memory unit.
Th
e physical location of the data in memory is
1 Basic Operation
therefore at offset d in page frame f.
55haTisPage Table? Explain~Sr p Because of the paging the user program sights the
Virtual Address to Physical Address in Paging with memory as one single contiguous space, it gr the
example. illusion that memory contains only one program.
- Ik problem of external fragmentation is avoided by But the user program is spread throughout main
using paging. Paging is implemented by integrating the memory (physical memory). The logical addresses are
paging hardware and operating system. translated into physical addresses.
Fig, 4.3.2 shows the operation of the paging hardware.
- Id this technique, logical memory i s divided into blocks
of lie same size called pages.
sec
°odary storage. Fig. 43.2 : Paging hardware
Phyakal Memory
Phy cal Memory
:
433 Paging example for a 32 K memory
W1 d l o c«” ’ ® 1 < ,on
' with4Kpages ______________
model of physical
Scanned by CamScanner
4-9 '1 . memory is presented with an item
FT Operating ------- - ------ The associauve m at same time. If there jj
“TZoil frame nZbeTTpage 1 is in frame numbe compared with E i n g value field is returned.
Scanned by CamScanner
ding System (MU - Sem 4 - IT)
4-10 Memory Management
Each operating system has its own methods for storing
Solution :
page tables.
TLB hit ratio, RAM access time t and TLB access time
Most allocate a page table for each process. A pointer T is given in problem.
to the pa£ e ublc 1S stored wi
tb the other register values
(1) Effective memory access with TLB (Ea)
(like the instruction counter) in the process contra!
Ea = {(TLB hit ratio) x ( T + t)) + (1 -TLB hit ratio) x ( 2 T + t)
block.
= (0.9 x (100 + 20) + ( 1 - 0 . 9 ) x ( ( 2 x 1 0 0 ) + 20)
When the dispatcher is told to start a process, it must = 130 ns.
the user registers and define the correct (2) Effective memory access without TLB (Ewt)
hardware page-tabie values from the stored user page Ewt . = 2T = 200 ns
table. (3) Reduction in effective access time*
, The hardware implementation of the page table can be = (Ewt - Ea) x (T/Ewt)
done in several ways. = (200 - 130) x (100/200) = 35 %
- The use of registers for the page table is satisfactory if Techniques for Structure
of Page Table*
the page table is reasonably small (for example,
256 entries). 1 . Hierarchical Paging
” Most contemporary computers, however, allow the
2. Hashed Page Table
page table to be very large (for example, 1 million
entries).
3. Inverted Page Table
For these machines, the use of fast registers to
implement the page table is not feasible. Rather, the Fig, C4.2 : Techniques for structuring page tables
P®ge table is kept in main memory, and a page-table
4.4.1 Hierarchical Paging
base register (PTBR) points to the page table.
Changing page tables requires changing only this one If the logical address space is very large such as 2 33 or
register, substantially reducing context- switch time.The 2m. the page table itself becomes extremely large.
Problem with this approach is the time required to - In this case each process may require may large
a user memory location. If we want to access physical address space for the page table alone.
Nation /, we must first index into the page table, using - So it would not be advantageous to allocate the page
016
value in the PTBR offset by the page number cable contiguously in main memory. Solution to this
E problem is to split the page table into smaller pieces.
**f*4A1
One method to achieve this i s to use a two-level paging
J’*’ Paged system TLB hit ratio is 0.9. Let the RAM access
tb algorithm, in which the page table itself is also paged.
** « 2 0 n s . and TLB access time T be 100 ns. Find out
Consider the system with 32 bit logical address space
' Effective memory access with TLB
with page size 4 K B . A 32 bit logical address is divided
Effective memory access without T L B in :
Reduction in effective access time. o 20 bit page number and
Scanned by CamScanner
Mei
4-11
Table
System (MU - Sem 4 U} 7T<ashe« PaS* 4
o 12 bit page offset ’ , hc address spaces are larger than 32 bits then %
Since paging of the page tables are done, a ' page table is used in which hash value „ used w
page number is again subdivide page number-
O 10 bit page number and The elements which are hashed at same loe *
' V a M is maintained at each entry in the ha*
o 10 bit page offset to aV id C0UiSi
is divided as folio* 5 : Jt is rey-y
necc3«“j ° “* ° n ' E** w-u
Thus the 32 bit logical address consistsof three fields:
Page offset
page number
d 1. The virtual page number
P2
10 12 The value of the mapped page frame
10
A pointer to the next element in the linl
Pao*tjia*o*
tab* In this, each entry in the hash table refers to a number
r
Hash
Scanned by CamScanner
ing System (MU - Sem 4 -
4-12
Inverted Page Table
Memoiy Management
. Generally the operating sy stem CQ
Page 1 rcfeienCe p,ace
mfercnce into a physical memory address virtual adlZ” '?' - P“t of the
°f "*■”'*> «s‘-
P ge
table may contain millions of entries.
g
m ““ “eissaved
- “““ usc
amounts of physical to sea h . | »'t the amount of time needed
the table when a page reference occur
0 001 physicai
ZZTZZi ??* " “
Th el
tables.
page ' «irc table might need to be searched to get a
C
' s search would consume more time.
- There is one entry for each real
To ease this problem, a hash can be used limit the
i nory in inverted page table . h “
search to one-or at most few-page-table entries.
aMess of the page stored in that real metnory loca(ion
°tder to explain this approach, example of the Compiler cart create the different segment for global
variables, code, thread stack, library etc.
page table used in the IBM RT is
ttfonstraied. In segmentation, a program may occupy more than one
£Vifi partition, and these partitions need not be contiguous.
virtuaj addre ss in the system is composed of a
Internal fragmentation is eliminated in segmentation
«. ’ < Pr °cess-id f page-number, offset>.
but, like dynamic partitioning, it suffers from external
fragmentation. In segmentation :
a
pair <process-id. page-number>.
o Logical address it is divided into two parts: a
cany out the work as a address-space segment number (s) and offset (d) into that
segment.
Scanned by CamScanner
Memory
4-13
noting System (MU - Sem 4 1 m ====g==aBSE ==
o X (d) always between 0 and segment limit 0 111 : Segment 0 is present in segment table.
Xwie « will occur indicating a«em P tmg [ 1 1<124 therefore physical address = 330 + 1 [ ] - 44
access beyond the end of the segment Fig. . .
indicates 4 segments of the program having Example 4.5 J
different sizes. Segment table contains base an
■
limit of each segment.
Segment Base Length
500
Limt
1 Sapnuril
0 800 500 1300 0 219 600
Sfl»-wo sc*- 1200
1
1200 3300
1700
2 wo -1
MOO SefnsntS 1 2300 14
3 1400 1700
Sirt-OM SUM > 1 4 0 0 3100
3 1327 580
3300
S gmnrt T«Ub
Se msri 1
4 96
4500
MOO
J 1952
Segrwit?
5500
What are physical addresses of following logical addresses.
Pftytic*) Memory (i) 0. 430 (ii) 1 , 1 0 (iii) 2, 500 (iv) 3, 4000 (v) 4, 112
Solution :
Fig. 45.1 : Segmentation example
(i) 0, 430 : Segment 0 is present in segment table. No*
Segment 3 is of 1400 bytes long and its base is 1700.
we have to check (offset < limit) or not If offset is less
Reference to byte 89 of sgment 3 is calculated as
than limit then physical address — base + offset
1700 + 89 = 1789.
430<600 therefore physical address ~ 2 J 4 + 430 - 6 0
Example 4.5.1
(«) 1, 10 : Segment 1 is present in segment table. KK [4
On a system using simple segmentation, compute the
physical address for each of following the logical address If
Therefore physical address = 2300 + 10 = 2310
address generates a segment fault than indicate so. ( 0 2, 500 , Segment 2 is present in segment table. 5®
5
8O (false) therefore segment fault and trap to OS
Segment Base Length
Possible to calculate physical address
0 330 124
1 676 125 an/ 00 1 Se
Bm «nt 3 is present in segment
8
2 99
° fore physical address = 1329 +
1 1 1 = 1729
3 [ 498 302
Scgmcnt 4 is
(I) 0 , 9 9 (II) 2, 7B (Hi) 1 , 2 6 8 (h/) 3, 222 (v)o ; i 1 1 (fJ Present in segment table- I l 3
Solution : faubanduaptoOS
S WetOC
Length given is limit of the segment. ’ physical address.
Scanned by CamScanner
i
parameters
Sr-
Ko- Mei Mana
Logical P(J
C generates P
address lo
Paging and seemem'* ’g“ g
’ advantages of both
« lcaI address
and 11
is divided into t Wo mah!
« me effect, ’e ° n ™ ple,nen,e<l
t°8«l*r >0
Pans: a
into two parts: a gment
page number ( p j number
and a page offset d Sharing
inTg “eXr “
segment.
11 5egIwnls div
multiple pages dT “ ‘d« i
>n
2. Table index The
Page number f~— - ■- - ths. wgnl
e re
t
1S 3,50
P’ge lable
maintained
Segment number
is
used as an us
into a p a2e “ ed as index t0 part of the logical address (containing
table. gment table. offsetand r —
«gment number) is 8plit „
Base address number and page offset.
1 uaac
aoaress
Segment
of each page in base Evcr
y segment table (
indicate starting indudcS segmajt basc
Physical memory segment limit -
physical — . and
ess of page table of that
is maintained by address particular segment.
of the
page table. segment in
main
memory and
F
segment base comnn ? *
portents '8 4 6 1 1
Segment
logical add
ress
Number has (SN)
three
denotes length of
the segment. Page Number (PN) and page offset.
Physical Memory , management unit uses segment number as an
'The combination
Segment base -ndex into segment table in order to locate the address
address of base <address
’ ‘ indicate starting
with page offset of page table.
physical address
defines the
of the segment in Then PN belonging to logical address is attached to
physical memory main memory and
h i g h order end of address of page table and it is used as
address that is segment base
sent to the an index to page table to locate entry in page table.
denotes length of
memory unit. the segment
5
Fragmentation to calculate
Suffer through Suffer through physical address.
internal external This frame number is attached to high order end of
fragmentation fragmentation
page offset to obtain physical address.
Segment Pag®
number number
Physical
[CPU SN PN|Pageoff r|}iXM Address
Page table 7 ] Page offset]
address
C3C3
Scanned by CamScanner
4-15
needed «o execute a process,
-dnn System (MU -8em4J2
W , fl nWry
\ s wapit * '
naM cn,ire bto
’ swapping ““
J f
|1r , >rv a a ttiet1
h . 1T. J -
Syllabus ij.iliiitl t ~' M n 9° — tas,ead
, ° DaJ! ing *ll° w s t0 SWaP
“ ° ‘n y
demand pag for ej[ecut i On at that time.
Scanned by CamScanner
- It saves swap time and the amounTZ **
p
needed. Ysical memory ------ Memory Management
T
sting the1 rv*
_ in demand paging, valid and invalM h -
8 needed
differentiate between those pages that t0 ">W Page L ' °?7"" page into an
rcstaitin
mcttl0l instruction. g the faulting
and those pages that are on the disk y
Pr0CCdure done b
- Demand paging keep more processes in for handlingg tthe
hepa p y operating system
Inemor
the sum of their memory n e e d y than
cn
- utilization as high as possible. * $uring CPU
Fig. 4.7.1 shows page table with val d
pages. Those pages which are in main ' nValid
- Page 1, page 3, Page 5, page 6, and page 7are on If dtsk is busy operating system has to wait. If not busy
are On
secondary storage, * search the page on disk and read it into main memory.
- Continuous allocution of memory to the pages is not reading of the page from secondary storage
P
necessary. The reason is , My page _ be J “ - comp etes, internal table and page table of the process
any available page frame. gets updated indicating page i s now in maw memory
- The page table maintains the information regarding Restart the execution of interrupted instruction from
newly transferred page.
the impression of having one contiguous block of
Syllabus Topic : Copy-on-Write
memory.
Scanned by CamScanner
Memory Manat
a==ssa!
=sS == \7r e placement algorithm and wo*
Th e simple Pa S t (FIFO). It throws out
Operating
dte basis of Xchthey i were brought i,
3 P00
pages in jgted with each page when it
‘ °f
allocated. Several
Th6 t nem
free pages for such request _____________ ______“ i1?intomain' ° ry -
bt0USh
t rithm always chooses oldest page fc,
Syllabus i <” 1V ;
replacement- a ma jntili
PageWP!?£?"!?5 '
------- -> (Dec. 1 — ■ M h 1
1 h
doesn’t care about which pages
_____ ----------“ ------------ replacement This algorithm and which are not. However, it is
Q '“ W r ite short note on vanou_ e c 2014. 5 M a r k s accessed
MU ■ D
policies’ ws
mt strategies J j in wtn<lo 2UUV.
“ der the reference strings. 0.2. 3.0. 1.3.4.M,
T ... accommodate the new
? Ater page fault will remain always iLd consider 3 available frames.
srsrsstM-**-
f
Reference string
2 0 3 4 3
0
o 2 3
5 5 5 3
3
3_ —1
2 2 2
0_ J_ £
. X- -anheevatua ymnmn _o
4 4 4 0
2
s
Ct num of p Z » should be minimum to
get the performance.
The generation of the reference siring » — Since first three pages were initially not tn main
artificially.
memory, references (5, 0, 2) causes page faults and
The reference siring can also be generated by listing the
address of each memory reference by tracing the
brought into these 3 free frames.
system. Reference to page 3 again causes the fault. To bring
The important factor to determine number of page page 3 in memory as per FIFO policy, page 5 is
faults is the number of page frames available.
These numbers of page faults are for a particular memory.
reference string and for page replacement algorithm for
To bring page 1 in memory again as per FIFO policy
given available number of page frames.
page 0 is replaced. Page 3 is already in meWOC1
The number of frames available is inversely
proportional to number of page faults.
Reference to page 4 again causes the fault.
2
It means that if more frames are available less number
To bring page 4 in memory as per FIFO policy, P
of faults will occur. is replaced. This process continues as sho
5UfferS
«
Scanned by CamScanner
gj ratrng SystemlMU - Sem 4 - 1
4-18
Memory Management
cw npare to all other page-replacement algorithms, m ,
gjgorithni has the lowest page-fault rate. The time of page's last use is associated with each
Page.
This algorithm replaces that page which will not be
ujed for the longest period of time . When a page must be replaced, LRU chooses that page
that was used farthest back in the past.
This delays the unavoidable page fault as much as LRU is a good approximation to the optimal algorithm.
possible, and thus decreases the total number of page
This algorithm looks backward in time while optimal
faults. replacement algorithm Looks forward in time.
algorithm replace the page on policy suggests that replace a page whose last
usage is farthest from current time.
This algorithm can be implemented with some
_ The optimal algorithm is unrealizable because it is
hardware support and is considered to be a good
impossible to determine the number of instructions that
solution for page replacement.
will be executed in the future before the page will be
This algorithm does not suffer through Belady’s
referenced.
anomaly.
- This algorithm does not suffer through Belady's We will again consider the same reference string 5, 0,
anomaly. 2, 3, 0, I, 3, 4, 5, 4, 2, 0, 3, 4, 3. Following is the result of
applying LRU page replacement algorithm.
, Again consider the same reference string 5, 0, 2, 3, 0, I
5 0 2 3 0 1 3 5 4 2 0 3 4 3
r—
5 £ £ £ 3 7 £ £ 3
5 0 2 3 0 1 3 4 5 4 2 0 3 4 3 0 0 £ 1 2 £ £
£ £ £ £ £ £ 2 2 2 4 4 0 0 0
0 £ £ 7 _4 4 £
2 3 3 3 3 3 Fig. 4.9,3 : Least Recently Used page replacement
algorithm
Fig. 4.9.2 : Optimal page replacement algorithm
Since first three pages were initially not in main
- Since first three pages were initially not in main memory, references (5, 0, 2) causes page faults and
memory, references (5, 0, 2) causes page faults and brought into these 3 free frames. Reference to page 3
brought into these 3 free frames. again causes the fault.
Reference to page 3 again causes the fault. To bring To bring page 3 in memory as per optimal replacement
P®ge 3 in memory as per optimal replacement policy, policy, page 5 is replaced because it is the page which
Pa ge 2 is replaced because it is the page which will not is used least recently.
be used for longest period of time. Next reference is to page 0 and it is already in memory.
Next reference is to page 0 and it is already in memory. To bring page 1 in memory again as per LRU
To bring page 1 in memory again as per optimal replacement policy, page 2 is replaced. Next reference
placement policy, page 0 is replaced. is to page 3 and it is already in memory. This process
continues as shown in Fig. 4.9.3 causing in total 11
page faults.
fetence to page 4 again causes the fault. Since page
<r Implementation of LRU
*ill no longer be referenced, it is replaced. This
continues as shown in Fig. 4.9,2 causing in Using Stack
8 page faults. Initially keep all the page numbers on the stack.
Recently Used Page - Remove the page from stack whenever it is referenced
Replacement Algorithm (LRU) and place it on the top of the stack.
C<M
We Optimal, LRU and HFO £*9® - Any time top of stack shows latest page number that is
re
q. placenwnt algorithms with Illustration. referenced and bottom shows the page which is not
FIFO and LRU pafiP replacement used for longest period of time.
____
Scanned by CamScanner
Memory Maria<
Using Counters
“« T'.:""' * -
. • M — « » «• ■ ““ w
“ l
““ ■ replacement, its reference bit B cheeked
incremented. the reference bit is 0 (old unused m
Other bits are shifted right by I and low order bit is This algorithm considers pair of reference bit and
discarded. This 8 bit shift register shows the history of modify bit. We get 4 combinations with two bits as:
page use m last 8 time period. For example, following
values of shift register shows the use of page as shown ° It is the best page for replacement which is
below. neither recently used nor modified.
o 00000000- Not used for last 8 time period (0, ! ) _ H jn( i icates page is g00 d foe
1 1 1 1111 1 - Used at least once in each period replacement as it is not referenced but modified- fl
to
o 110001 00 - This page is uscd more recently than be written out before replacement*
one with a shift register value of 01 1 101 11 ) This page may as it sb0 * 5
The least recently used page is the lowest number ntly usedbutnotmodificd
when this shift register value is considered as unsiLS
8ne<1 ThlS Page is rc
integer. THrL ently used and modify
The number of bits used is hardwarec
. . pendent. If
Scanned by CamScanner
ng System ( MU_- Sem 4 - IT)
- This policy assumes that, those pages which are 2, 1. 2, 0. 1. 7, 0, 1. Calculate the Page Faults applying (i)
referenced for more number of times will be needed Optimal (ii) LRU and (iii) FIFO Page Replacement Algorithms
again. for a Memory with three frames.
- A counter is used for each page and incremented with
each memory reference.
Solution :
Optimal Algorithm
7 0 1 2 0 0,3 4 2,3 0,3 2 1,2,0,! 7 OJ
Tat
alPage faults = 09
nF0
Algorithm : String = 7, 0, 1, 2, 0, 3, 0, 4, 2. 3, 0, 3, 2, 1, 2. 0. 1. 7,0, 1
Page faulta = 15
2,0. 1.7,0, 1
A1
8orithm : String = 7, 0J , 2, 0- 3 ’ 4> 2 3
’ ! 3
7 0 1 *£
n _4
n a
Scanned by CamScanner
Mei
4-21
Operating System (MU - Sem 4 - J ■
Example 4.10.2
1 , 2, 3. 4, 2, 1, s. "• " Mr all frames are initially empty, so * l
Solution :
( 1 ) LRU
6 2 1 2 3 6 3
String 1 2 3 4 2 1 5
1 1 1 1 1 1 1 1 6 6
2 2 2 2 2 2 2 2 2
3 3 5 5 3 3 3 3
4 4 6 6 7 7 1
Page faults for LRU = 10
(2) FIFO
String 1 2 3 4 2 1 5 6 2 1 2 3 7 6 3
1 1 1 1 5 5 5 5 3 3 3 3 1 1
2 2 2 2 6 6 6 6 7 7 7 7 3
3 3 3 3 2 2 2 2 6 6 6 6
4 4. 4 4 1 1 1 1 2 2 2
Page faults for FIF O = 14
Example 4.10 J
4.3,2,1,4AM, 3,2.1 ,5
Assume frame size = 3, How many page
Solution :
(1) FIFO page replacement algorithm
3 5 4,3 2 1 5
7 7 5 T
7 4_ 2_ £
3 3 3 1
Total number of page faults - 9
3 2
3
5 4,3 2
7[|7
3 3
7 7 7 2
1 5
2
7 7 7 1
t
Total number of page faults = 7
5
7 7
(3) LRU page replacement algorithm
4
7 4 3
5 4,3 2
1 5
3 _3 3 7 7 7 7
7 7 7
4
ft 7 7 7
3
7" 7 7
Scanned by CamScanner
System (MU ~ Sem 4 --rn
4. 10 M 3*?
Hit and Miss using (flu, Memory Management
raptao
p8ge(ramesi zeis3.0,4,3 >2,M,6,3,0.8, 9 ,3 i8>5 *'W Policies for , he
(1) tB0 0 4 3 2 1 4 6
0 £ 0 £ 7 £ £ £ 3
6 = Hit
7 7 1 7 1 7
3 3 3 4 7 4
£ 4
3-Hit 0
0 2 £
6
9 3-Hrt 8=Hrt 5
4
£
3
Number of hits = 04, Miss = 1 0
(3) FIFO
8 = Hit 5
Solution:
eSize = 3
Page Replacement
Number
of Hits - 8 Miss _ 12
Frame 2 0 0 0 5 0
0 0
0 0 0 0 0 0 0 0 0
2 2 2
1 0 0 0 0 2 2
0 0 0 2 2 2 2 7 7
2 0
PF
M Page Replacement
n er
£ Hits = j 3 d Miss = 7
0 0 0
2 0
Frame 0 5
5
2
0 0 0 0 0 0 0 0 0 0
0 0
i 0 0 £
3
Scanned by CamScanner
4 23
‘-’''"’ Repl.ecment
HJaruf M i s s ® f n
L Frame 12 0 2 7 5 0 7
© |_4 2 5
0 7 0
2 2 4 0 0 2 7 7 7_ 7 7
0 3 3 3 0 0 0_ 0 7
0 0 0 0 3 o
12___ 3 2 2 2 2 5 5 5
£
Y Y S
Fmmc Size » 4
Wo Page Replacement
for
N“mhcrc>fHits= l andM .M = g
(10
f F me 2_ O 2 0 2 2 2 5 £
rp 0
2 2 2 2 2 2 2 2 7 7 7 2 _7_
[j 2_ _2_ 2 2 2_ 2
7
J
0 0 0 0 0 0 0 0 0 _0 2
2 2 2 £
_2 J
3 3 3 3 3 3 3 £ 3 3 0 0_
2 £ £
3 4 4 4 4 5_ 5 5
4 4 4 4 4 4 5 5 5
PF Y Y Y
Frame Size = 4
Optimal Page Replacement
Frame 0 0 5 Q
0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
When frame size = 4 then number of hits are mote all algorithms for given page string.
MU - J u n e 20 T 5. 10 Marks
What is paging. Explain LRU t FIFO, and OPT page replacement policy for the given page sequences. Page frame size is*
2 f 3, 4, 2, 1, 3, 7, 5, 4, 3, 2, 3, 1
Calculate page hit and miss.
Scanned by CamScanner
Management
2 3 4 2 1
7 5 3
~ 3* T
7
Sit 2 3 1
7
1
Zlr?
4 7
4 and Miss = 9 7
L.
2 3 4 2 1 3 5 3 2
I
7
~2
3 7 3
I
7
4
1
f £r LRUHit = 4 and Miss = 9
(jj)Optimal
5 4 3 2 3 1
2
£
4
5
fa Optimal Hit = 6 and Miss = 7
5 2 2
2
3 2 2
3 3 3
PF
2
5
5
2 6
Scanned by CamScanner
Mai
4-25
Operating S y s t s m (MU - Se m 4 J raj*
p,e
i«j upumai
Frame 1 2 3 2 1 5 2 r 6 2 r
1 1 1 1 6 6 G r
0 I 1 1 1
2 2
2 2 2 2 2
1 2 Z 2 2
3
5 5 5 5
2 3 3 3 5 5
PF - - Y - - Y ! The
Y Y Y
Frame Size = 4 l K lJ
) FIFO ------r
6 _3_J 1 3 6 i 1 £T
2 1 6 2 5 4
Frame 1 2 3 2 1 5 0
6 6 6 6 6 6
I 6 6 T 6
0 1 1 1 1 1 1 1 1 6 6
2 2 1 ’ 1 ' 1 1 1 1 1 1
1 2 2 2 2 2 2 2 2 2 2 I
2 3 3 3 3 3 3 3 3 3 3 3 3
13 3 , 3 J PF
5 1 5 5
3 5 5 5 5 5 5 5 5
H—
5
1 5
i 1
PF Y - . Y - - - Y - I- -
Y Y • • Y - i Y
Fn
(it) L R U 0
Frame 1 2 3 2 1 5 2 1 6 2 5 6 3 1 3 6 1
14 L3 ' 1
1
0 1 1
2
1
2
I
2
1
2
1
2
1
2
1
2
1
2
1
2
J
2
1
2
3
2
3
1
3
1 1
3
1 1
3
1
P-EEi i
F1 uTii l
!
2 3 3 3 3 3 3 6 6 6 6
16 6 6 6
16 W
3 5 5 5 5 5 5 5 5 5 5
5 5
PF Y Y Y - - Y - • Y - 1_ • Y Y - - - Vh
Frame 1 2 2 6 2 6 3
0 1 I 6 6 6 6 6 6 6 6
1 2 2 2 2 2 2 2
2
2
\1 2 2 2 2
3 3 3 3 3 3 3 3 3 3
3
5 5 5 5 5
PF Y Y
Frame Size
Hit Miss Frame Size = 4
Hit Miss
FIFO 6 14
FIFO II 9
LRU 9 11
LRU 10 10
OPTIMAL 11 9
OPTIMAL 1 1 3 1 7
Scanned by CamScanner
-non System (MU - Sem 4 - IT)
4'26
MU - Dec 2015 10 Mar k s Memory Management
LRU 15 page faults ii) FIFO, 16 page faults iii) Optimal. n faute
••Y” in bottom rows denote the page fault
fu)H?O
Frame
PF
ffl Optimal
5
Frame
PF Y
Pullon:
Sitta
Scanned by CamScanner
4-27
im
2 2
2 2 2
0 0 0
0 0 0 0 0
0 0 0 0
0 0 0 0
5
PF
Frame 6 0 5 2 0 3 0 4 2 3 0 3 2 5 2 0 5 6 0 5
0 6 6 6 2 2 2 2 4 4 4 0 0 0 5 5 5 5 5 5 5
1 0 0 0 0 0 0 0 0 3 3 3 3 3 0 0 0 0 0
2 5 5 5 3 3 3 2 2 2 2 2 2 2 2 2 6 6 6
PF Y Y Y Y - Y • Y Y Y Y - - Y - Y - Y - -
S
If Pa gc fault occurs prior to an executing instnKtio11
93 frames are for the user process. “ d rcmaini »g
If we consider the pure demand paging all <n niplete, the instruction must be started again- As
would at the start be put on the free-ftatt fet We must
sufficient frames to hold aU
ferem pages instruction
l
“ r ercnce.
Skate
? ie> for allocation of frames
W0Uld fKe
[ erent strategies for allocation of I
Scanned by CamScanner
MU - Sem 4 - 1
4-28
Me g ana men
for A process should have some minimum number of
location °< Tramea
frames to support active pages which are in memory- It
helps to reduce the number of page faults.
t . Equal allocation
If these numbers of frames are not available to the
2, Proportional allocation | process then it will quickly page fault.
To handle this page fault, it is necessary to replace the
3. Global vs local allocation existing page from memory.
: a oca on
Since all the pages of the process are active, it will also
C43 ®f frames
need in future. So any replaced page will cause page
b gqual allocHti° n fault again and again.
p number of processes and q number of - Since in paging, pages are transferred between main
In this case every process will get p/q frames, memory and disk, this has an enormous overhead.
to cs ample suppose 5 processes and 93 frames Because of this frequent movement of pages between
Then 93/5, that is each process will get 18 main memory and disk, system throughput reduces.
and 3 will remain at free-frame list. - This frequent paging activity causing the reduction in
* t Proportional allocation system throughput called as thrashing.
h this allocation, frames are allocated to the processes Although many processes are in memory, due to
thrashing CPU utilization goes low.
as per their needs. Suppose 60 free frames available.
Process Pl has size 10 KB and P2 has size 128 KB. When operating system monitors this CPU utilization,
And if page size is I KB. Then (10/(10+128) ) it introduces new process in memory to increase the
♦60-4.34, say nearly 4 frames allocated to P l . P2 degree of multiprogramming.
win get (128/(10+128) ) * 60 = 55.65, that is 55 Now it is needed that the existing pages should be
frames. replaced for this new process.
Scanned by CamScanner
4-29
| > .._ r . . r Mil -Sent 4 -111 .. --------------—
If sufficient frames are not available i t will suspend the had been created in the conservative way.
process. In this way working set model helps to prevent
Advantage
the thrashing
I/O is not needed programming makes easier.
Syllabus Topic : Memory-Mapped Files
Disadvantages
Scanned by CamScanner
tem (MU - Sem 4 * IT)
4-30 ■ *
operating system may instruct the devi- ,
Memory Managerrient
nCem
c o *S
°W n
to CPU interacts with the
operating system can know the device's Twn and also with the device data buffers,
pttons are available to achieve the same.
' re ading U* ref avaihble with device control lrSt
.
toethod, I/O port number is allotted to each
This state can be: whether device is ready to , '°" lTOl re
« is,M *hich is 8- or 16-bit integer.
w command, and so on.
P” 1 space is formed by collection of all VO ports
Besides the control registers, many devices are with
is protected so that other than OS ordinary user
0131 the programs cannot access it.
' data buff" operating system can read
f
4.16.1 Buddy System
(b) F Q. Explain Buddy system.
s
The kernel produces and wipe outs small tables and
it
Two address spaces buffets repetitively during the course of execution, each
d
of which requires dynamic memory allocation.
In SVR4, there is dynamic allocation of several objects
o
bv kernel as per requirement; for example these objects
X proc structures, v-nodes, and file descriptor blocks.
te
Several of these blocks are having considerably small
siK with compare to usual machine page size. As a
a kernel meraory aUocauon
Xit. for '
paging system seems non efficient.
an 7 qVR4 a revised buddy system is used. Kernel
<15.1 : (a) Separate I/O and memory space (b)
Memory -mapped I/O (c) Hybrid ' rXroory management requires the fast precess of
allocation and free operations.
As
an example, computers display pixels •nre disadvantage of the buddy system ts the tune
raMt
is possible because of video or the ' ded lo fragment and combine blocks.
bu
ffer that offer facility to lbc prOgfa
Scanned by CamScanner
Memory M,
4-31
- Sam 4 - 1
aCCO
‘ in '3 rf locally fee blocks of particular si*
size (Li<=Ai)*
rr. ir
:x Di = Ai-Li = Ni-2Li-G
The lazy buddy system uses the following parameters : - Any request for memory is first rounded up to a po
o Ni - Current number of blocks of size 2 of two, say 8 pages. The full memory chunk is
divided in half.
o Ai - Cunent number of blocks of size 2 that are
- Since each of these pieces is still too large, the lower
allocated (occupied).
piece is divided in half again. Now suppose that a
o Gi - These are number of blocks that are currently
second request comes in for 4 pages. The smallest
globally free having size 2 ; these blocks are
available chunk is split and half o f it i s claimed.
qualified for combining; if the companion of such
a block turn out to be globally free, then the two
blocks will be combined into a globally free block
16 16 16
of size 2 ' . If standard buddy system contains
free blocks (holes) then all these could be though
as globally free. 32
4 ;
o U - These are number of blocks that are currently
------------
locally free having size 2 ; these blocks are not 16 Allocated
qualified for combining. Although the companion Allocated Allocated
of such a block becomes free, the two blocks are a -J
not combined. Instead, the locally free blocks are
kept awaiting future demand for a block of that Fig. 4.16.1: Operation of the buddy algorithm
size.
4.16,2 Slab Allocation
The following relationship holds :
deal ,ocate
" for particular uses.
Usually, coalescing does not occur after .
block, which leads to minimum accounting manae ° Cat *on mct
hod used for user virtual tpe®*
ba
operational costs. Locally and globally free bl v XT “ « mel memory
— - — - ...
■■ _____ LOSS
Scanned by CamScanner
r (MU • S&m 4 - IT)
4-32
MemoryM agme
the virtual memory scheme, a buddy algorithm is
50
' memory for the kernel can be allocated and
U
*\ j j6 d in units of one or more pages,
minimum amount of memory that can be allocated fahdAiti
3-KB
' way is one page. objects
h _______; ____
yay like the buddy algorithm and moved between lists As an example, a 16-KB slab (made up of four
accordingly. contiguous 4 KB pages) could store eight 2-KB objects.
At the start, all the objects in the cache are marked as
The memory is allocated to kerne) data structures using free.
dab, A slab comprises one or more physically
At the time of requirement of new object for a kernel
contiguous pages. A cache contains one or more slabs.
data structure, the allocator can allot any free object
- A cache is assigned to each unique kernel data from the cache to fulfill the request Then this assigned
structure. For example, cache for process descriptors, object from the cache is marked as used.
file objects, and a cache for semaphores, and so on. In Linux at any given point of time, a slab may be in
- The objects that are instance of the kernel data structure one of three possible states :
are occupied in the cache which represents this data 1. Full : All objects in the slab are marked as used.
' This means, the cache representing process descriptors 3. Partial : The slab consists of both used and free
objects.
stores instances of process descriptor objects.
The relationship among slabs, caches, and objects Syllabus Topic : Other Considerations
shown in Fig. 4.16.2.
4 j 7 other Considerations
h the following Fig. 4. 16.2 two kernel objects having 3
size and three objects having 7 KB size is shown.
4.17.1 Prepaging
objects are stored in the respective caches for
Demand paging leads to many number of page faults
and 7 KB objects.
" whTprooess starts execution. This is due to attempt to
h slab-allocation algorithm caches are used to obtain the initial locality into memory.
el objects. A number of objects are assigned can occur at other times also. For example,
he after the cache is created. ' insider restarting of swapped-out process having ah
7116 pages on the disk, and requires each page to be
of the associated slab decides the number o f ched by its own page fault.
o Kcts in the cache.
p Ug is nothing but trying to stop this high level of
initial paging-
Scanned by CamScanner
Memory M a n ?
4-33
Operating System (MU - Sem 4 - IT)
J““ ' "«=
The policy is for bringing all needed pages into size.
memory at one time. Some operating system’,
TLB stores the working set of process. Otfte
example, Solaris prepage the page frames for small
process will require more time resolving
files. references in the page table rather than the TLB. '
Working set model permits to keep each process a list
If number of entries in the TLB i s increased the, -
of the pages in its working set. If it is required to
reach also increases.
suspend a process, because of an 1/0 wait or a lack of
Other scheme to increase the TLB reach is cit c
increase the size of the page or offer multiple
For the resumption of such process due to I/O has
sizes.
finishM or sufficient free frames have become
available, it is possible to bring back into memory its It may lead to fragmentation as many applica
Prepaging may offer an benefit in some cases. The manage TLB for multiple page sizes instead
question is simply whether the cost of using prepaging hardware manage it.
to
. P e another page fault as it” 7n ex
Scanned by CamScanner
em (MU - Sem 4 - 1
4-34
table it needs to search the virtual Da „ „ , Memory Management
firing store. In kernel this situation is Page Table? Explain the conversion of
dled carefully. dual Address to Physical Address in Paging with
example. (R e f er sect]On 4 3
program Structure
Q.
paging then it is possible to improve systenj (Jun® 2015, Nov. 2015, Dec. 2016)
Q. Explain the hardware support for paging.
If data structures and programming structures carefully (Refer section 4.3.5) (1 0 Marks) (Dec. 2016)
selected, then it can increase locality and hence
Syllabus Topic : Structure of the Page Table
decrease the page-fault rate and the number of p ages jn
working set. Q. Discuss various techniques for structuring page
tables. (Refer section 4.4) (1 0 Marks) (Dec, 2014)
4 18 Exam Pack Syllabus Topic : Segmentation
(University and Review Questions)
Q. What is segmentation? Explain it with example.
What
i» paging ? (Refer section 4.3) (5 5)
Scanned by CamScanner
j LbOperating System (MU - Sem 4 - 1’ 4-35
Memo
Q. Compare Optimal, LRU and FIFO Example 4.10.9 (10 Marks)
page
replacement algorithms with Illustration,
Syllabus Topic : Allocation of Fra
(Refer section 4.9.1)
Q. Explain different strategies for allocs
Q. Compare FIFO and LRU page replacement (Refer section 4.11) n
Scanned by CamScanner
chapter
Module V
ement
Syllabus Topic : File System - File C o n c e p t o The information should not loss after termination
of the process using it.
Scanned by CamScanner
_ _ Storage Manao
|»F Operating System (MU -
Files are used to store information which can
each file, for example, the date and time of file creation
later on. For storage and retrieval purpose, different ty
and the size of the file.
systems offer different operations. For the operation
- Such extra information associated by operating system create, write, read, reposition, operating system offer
is called as attributes. The lists of attributes are not system calls. The majority of common system calls re
same for all the systems and vary from one operating to files are listed in Fig. C5.L
system to another.
Common system calls |
- No single existing system supports al! of these relating to files [
attributes, but each one is present in some system.
Some of the attributes and its meaning of file 1. Create
Hidden flag 0 for normal; 1 for do not display in Fig. C5.1 : Common system calls relating to files
listings
1. Create
Read-only flag 0 for rcad/write; 1 for read only
The new file is created without data. It is needed to
ASCII/binary flag 0 for ASCH file; 1 for binary file
locate the space for this created file in file system. Tl*
Lock flags 0 for unlocked; nonzero for locked
intention of the call is to declare that the file is created
Key length Number of bytes in the key field and some of the attributes needs to be set.
Time of last Date and time the file was lasl 2. Delete
access accessed
File need to be deleted to release the disk space
Time of last Date and time the file has last
change occupied by tile when it is no longer required.
changed
Maximum size 3* Open
dumber of bytes the file may grow
_________________ Before making use of file, it is required to open the file
System flag () for normal files; 1 for system file first by any process. To have quick accesses in future
all the attributes and disk addresses are bought ifi*°
5.1.3 File Operations main memory.
4. Close
Q
\ Explain various file operations in brief.
After use of the file completes, all accesses
finished. The fetched attributes and disk address
memory are no longer required, so the file should
Scanned by CamScanner
system (MU - Sem 4 ■ IT)
5‘3
Storage Management
is vided in blocks and is written' J The rules for flu
. nammg are not same for all systems,
Jl'ng a fife c0 "'P e l writi
"E of the file’s last block.
S rOni s stem to
nnpftif’ system, but all current
. Head
as l allow strings of one to eight letters
nan
j; M «S. If an operating system
tie name of the file. Generally, the bytes are fetched the 1file
n gU1SheS the of a
file, it can then operate on
the r i m logical Ways
fin® the current posmon. The system should maintain
.g s and special characters are also allowed to use
is 10 begin. The caller must state the am ount of * giving the fife names. UNIX operating system
jaU desired and must also offer a buffer to put them in. ifferentiates between upper and fewer case letters,
whereas MS-DOS does not.
x.
Windows 95, Windows 98, Windows NT and
' — -- -------------- - -v mi. spcciry rife name
Windows 2000 support the MS-DOS. fife system and
and information to be written to the file. Writing is
thus inherit its properties.
Fife name is divided into two parts - name and
increase if writing starts from end of the fife. In this
extension which are separated by period character.
User and operating system can recognize the type of
file from name only.
of the file, the previously existed data will be
overwritten and vanished permanently. MS-DOS allows the fife names containing 1 to 8
characters along with an optional extension of 1 to 3
4 7. Append
characters. On the contrary, in UNIX user has a choice
With the help of append system call; data gets of deciding the size of extension. In UNIX, file can
appended only to the end o f the fife. Systems offering have two or more extensions.
less number of system calls do not generally provide
Examples of file extension, Its meaning and
append, type
* I Seek
- Table 5.1.1 shows the some examples of file extension,
The seek system call is used to place the pointer at a its meaning, and type.
particular location in the file. It is needed for random
Table 5.1.1
access files to specify from where to obtain the data.
After this call has completed, data can be read from, or Extension Meaning Type
Witten to, that position.
CompuServe Graphical
Get attributes
gif Interchange Format Image
frocesses frequently need to read file attributes to image
c
°nipfefe theij- designated work. Get attributes system
World Wide Web
is used for this purpose.
html Hypertext Markup Web page
101
Set attributes
Language document
can change the some attributes of file after its
Complied machine
<1 crca
h°O- This system call makes that possible. obj, o Object
language not linked
111
Rename
Ready to execute
needs to change the name of an existing t de. This
exe, bin, machine language Executable
' Stern call makes that possible. com program ____
cess
&ves the name to the file when it creates it Libraries of routines Library
lib. a, dfi
co ess
C* «ipletio n of the execution, even though pw for programmers ____
file still exist and other processes can
---------------- —
Slha
\ 'filebythe same name. __
Scanned by CamScanner
Stora
8 the header
pro<X
Program ltsel f. “e
... the test and mcflK cf
data <y
Scanned by CamScanner
System (MU - Sem 4 - 1
Scanned by CamScanner
Storage Manage
5-6
o raring System (MU - Sera 4 JT)
structure, application should have included its own order. Il is because; disks allow random access to any
file block. *
code. On the other hand, all operating systems must
support minimum one structure of an executable file. It also became possible to access records by its key
(June 15) able to access the record for that train directly instead
of reading hundreds of records of other trains first.
Q. Explain different file access methods.
MU - June 2015. 10 Marks For the random access method, the file operations must
be modified to include the block number as a
Following are the different access methods for files.
parameter. Thus, we have read n and write n, w erc n
Scanned by CamScanner
Si >m (MU - Sem 4 - it
rati
5-7
« read operation gives the pc Storage Management
tory Systems
Root directory
tbc
jpd to find desired record.
Scanned by CamScanner
Storage Mi
5-8
rating System (MU - Semjjn
User d recto
S
P Q A First collection can be the group of flles related to one
subject a second collection of files related to second
X X /"< ( s i (?) * ----- User files
pj © © © 09 © subject and so on. Here, some way is required to group
Root directory
Fig. 5.1.4 : Two-level Directory Systems
Advantages
and S which belongs to different users. Users Q $
- Solve name collision problem as every user has have created the subdirectories.
separate directory.
As user can create random number of subdirectories-’
- Independent user gets isolated from each other.
offers a commanding structuring tool for us
Limitations organize their work. This i s the reason, nearly 311
If the users are co-operative, that is, working OQ modem file systems are organized in this approneb-
common task, then some system does not allow Advantage
accessing the other user’s files. In systcm ,
With a hierarchical directory system, in addih01’
permitted, one user must have the ability to name a fife
their files, users can access the files of other us ‘
Scanned by CamScanner
m (MU “ Sem 4 .
if _____ -~ _ _ ?_ 5-g
psth Naffi®® * ........ __ Storage Management
2. Delete
-♦ 1. Absolute Path name
3. Opendir
5. Readdir
Fig. C5.6 : Types of path names
6. Rename
I. Absolute path name
7 . Link
[t consists of the path from the root directory to the
file. . 0. Unlink
, The meaning of the path /usr/myfolder/myfile is that, Fig. C5.7 : Directory operations
[he root directory contains a subdirectory user, which
"fr 1. Create
in turn contains a subdirectory myfalder, which
contains the file my file. Empty directory is created excluding dot and dotdot
(. and ..), which are placed there automatically, by the
4 1 Relative path name
operating system,
- ft consists of the path from the current working “4 2. Delete
directory to the file.
If only single dot and double dot (. and is present in
- A user can assign one directory as the current working directory then it is treated as empty, single dot and
directory, in which case all path names not beginning double dot within directory cannot usually be deleted.
at the root directory are taken relative to the working
-> 3. Opendir
directory.
Directory can be read to list all the files from it
' If the current working directory is /usr/myf older, then Directory should be opened before reading just
the file whose absolute path usr/myfolder/myfile can opening and reading the file,
he referenced simply as myfile.
-> 4. Closedir
to UNIX operating system the elements of the path are
After reading completes, a directory should be closed
separated by /. In Windows the separator is t The same
to free up inner table space.
Pat h /usr/myfolder/myfile in UNIX, is specified
5. Readdir
Widows as \usr\myfolde myfile- * t h c fir ‘ chara€tcr
of
Path is separator then path is absolute path. If during It returns the next entry in an open directory, readdir
Wor
Lng, program always needs a particular ft always returns one entry in a standard format
should use absolute path to access that file froin irrespective of possible directory structures is being
CUntnt used.
working directory.
6. Rename
directory Operations __ Directories can be renamed just like files. Rename
Q/ 2' ----------------- —-----------
renames the directory.
VWdifferenl directory operatio __— -----—
<+ 7. Link
"“wage the directories, with
Due to linking, a file appears in more than one
a C n ore
* ' dissimilarity from syste .. directory. Link system call specify an existing file and
to
Wm calls for files.
Scanned by CamScanner
Storage
5-10
Operating System (MU
, implementation of mounVunmourrt
its path name, and creates a link File systems can be on same or different devices.
to the name specified by the path. In this fashion t . rhrsc file system can be viewed as single Fll
the mount these j &ie
system Files can be moved between different director of
8. Unlink different file systems thereby appearing as a singfe *
with file systems as shown in ri the Link needs to be created from R l to P12. To this shared
and rectangles shows directories. file now two absolute pathnames exist to this shared file as
Disk 1 Disk 2 shown in Fig. 5.1.8. These are /P/P1/P12 and /R/RUP12 In
directory R l the same file can be called by different name
sav R I . In this case, pathnames /P/P1/P12 and /R/R1/R1
would be the same.
p) CO)
Now the command cp/B/R/A/R copies the resultant file execute link system call. Error messages w®
R. In UNIX a facility is given to mount or unmount a file at ■outputted if user is not super user.
pre specified time. The mount and unmount system calls are The pa* name /P/P1/P12 is parsed to obtain
used for this purpose. A system administrator does the
mounting at the time of booting of UNIX. A large number
i-node record is accessed and number of lb* ’
of file system are supported by UNIX for mounting.
incremented.
Scanned by CamScanner
Operating System (MU - Sem 4 - FT) ___
, Storage Management
in order to have disk consistency, the i-node
n
back to disk. the file, then the new blocks will be listed only in the
The path name /R/Rl is parsed to obtain the i. no<fe „ F directory of the user, who is actually doing the append.
the directory. The content of the directory is then read The changes will not be visible to the ocher user, thus
free entry in directoty is located and it makes .sore that overwhelming the intention of sharing. Following are
two methods to handle this problem.
file with name S I not present in directory. If pre
enor message is outputted and exit operation is ° Instead of listing the disk blocks in directories, it
performed. is listed in data structure related to the file, just
like i-node in UNIX. The directories would then
The entry of the Jinked file is done in /R/R( W jth S1
point just to this data structure.
fife name and i-node number stored in step 2.
jj directories are then written back. ° When Q link to S’s file, system create a new file
a
of type LINK and enters this file in Q’s directory.
The new file contains the path name of the file to
5 1 12 Working of Fifes
which linked. In our example, it is S . When Q
_ While working on a common task, many users need to read from linked file, the operating system note
share their files. If these shared file appears that it is type LINK file and search the name of
simultaneously in different directories belonging to the file and read it This is called symbolic link
different users, then it will be convenient to all users. approach.
, Fig. 5.1.9 shows that one file of user S appears in the I The disadvantage of first method is that, when Q links
to the shared file of user S, i-node records owner of file
as S and link count becomes 2 which was initially 1.
Now system knows 2 directory entries pointing to the
Root directory
file. If S removes the file and clears the i-node, then
Q’s directory entry will point to ihvalid i-node. If later
on i-node is assigned to other file then Q will point to
the wrong file.
Q R S
Due to link count in i-node, operating system will
come to know that file is in use but unable to find all
the directory entries of that file. The solution to this
Q R S S S problem is to remove S’j directory entry, but do not
clear the i-node and keep it with count set to 1.
Now Q is the only user having a directory entry for a
Q Q Q S file owned by S. Here system will assume that file
belongs to S until Q decides to remove it. When file is
Link S S deleted, count goes to 0 and no longer belongs to any
user.
Shared file
The disadvantage of symbolic link is that, extra
Fig. 5.1.9 : File system combining a shared file operating cost required. The LINK file having the path
must be read, and then parsing of path is done and
Problem In sharing the files
followed, component by component, until the i-node is
Suppose directories actually do contain disk addresses searched.
then, in above example, copy disk addresses of S s
All of this activity may require a considerable number
directory should be made available in Q’s directory of additional disk accesses. Every symbolic link
hen the file is linked. requires additional i-node, as is an additional disk
The user who actually perform append operation, the block to store the path.
appended block appears only in his directory* In Although path name is short, the system could store it
e
mple, If either Q or S perform append operation to in the i-node itself for optimization purpose.
Scanned by CamScanner
Store Mai
5-12.
Qnnmtino System (MU - S e m j J T ) Execute
Sullabun Topic: Sharing A loading and execution of p
but copying it is not allowed.
Re4id
4.
5.1.13 File Sharing
a rend access right allows the use to teed the flle
q ( Write nota on ‘access rights’ C.y work, together with copying and execute
5. Appe nd
The user can only add data to the file at the end.
6. Update .
5.1 .1 3(A) Multiple Users — — t update
The upo 1
access right allows
. file’s thedata.
user to
7 Changing P rolec,,on
the access rights assigned to ote,
The file system shou. J users . It
permitting widespread file s * Th
offcr a many ‘ “ Normally this right is associated only with
is also a responsibility “ ' he way of file accessing. In X of the file. The owner is allowed to extend
alternatives in order to co ( Kss permissions Xht to other users in some systems
general, it important to grant partly g. Delete
The user is allowed to delete the file from the fik |
OT n£W
,S I0
T L P
Xess rights has been used. The
y
to user form a hierarchy, wih
These rights assigned to usei
5. Append
Specific user : Individual users having its own us
- User groups : A group of users who belong 6
6, Update *
particular user group. The system keeps tract
7, Changing protection membership of user groups.
AU : Authenticated users of this system/
8. Delete
<r Simultaneous Access
' . .a fro
Fig. C5.8 : Examples of access rights
- It is necessary to protect the share *
-► 1. None access right simultaneous updating from more than one u
more than one user granted access to appen
To put into effect this access limit, the user is restricted a file, the operating system or file managed
from reading the user directory that contains this file. must implement some way to restrict it.
A brute-force scheme permits a user to
X Knowledge
complete file when it is to ,be updated,
With knowledge access right, the user can find out
possible to lock individual records during upd
Scanned by CamScanner
3(B jRemote File Sy s t em 5-13
- Remote file system permits m o u n t i n g of one or more computers. This allows secure single sign on for all the
users.
file system from one or more remote computers.
Machine storing the file i s server and machine from Failure Modes
which file is accessed is client. As there can be failures in local file system due to
A server can offer the s e r v i c e to multiple clients, and a various reasons, there are more failure modes for
remote file system. This is due tq the interference in
client can request to multiple servers. This depends on
communication over network and complexity of
tow client-server facility is implemented.
network systems.
The server generally states the available files on a
There can be interruption i n network due to hardware
volume or directory level.
failure, poor hardware configuration, or networking
Client is specified by network name or IP address. As implementation issues.
tose can be spoofed, unauthorized user can access the
A single failure can interrupt the flow of DFS
server. commands.
Secured authentication is required using encrypted Due to crash or failure in server remote file system
fe will be unable to reach. In this case, system can either
y>- During exchange of these keys, unsecured access
10 terminate all operations to the crashed server or delay
*• also possible.
,n use the operations until the server is again reachable.
UNIX and its network file system (NFS), the “
Implementation of the failure semantics is a part of the
IDs
on the client and server must remote-fte-system protocol.
’“‘hentication. In mismatch case, the server w
o f data can be resulted due to termination of
able
to decide access rights to files.
Chuted Information Sy»»n« from failure requires maintaining cras the
Recovery hesstate
but
"‘“’Putation.
Scanned by CamScanner
Storage
6-14
Operating System (MU
user advances the pointer then it affects all sharing system are put into effect by mechanism which
users. Here, a file has a single image that interleaves al! offered by protection. Some of the policies
accesses, in spite of of their origin,
Session Semantics
are defined by the individual user of the system to
Following consistency semantics are used the Andrew
protect their own files and programs.
file system (AFS).
rt puntvnv j oner
Other users who have file open, can not immediately
different and put into effect the different types of
view writes to this open file by a user.
policies. Different types of applications have different
Once a file is closed, the modifications done in it are
types of resource use.
visible only in sessions starting later on. Already open
The policies designed should allow offering this
instances of the file do not reflect these modifications.
resource use need. The resource use of the applications
Immutable-Shared-Files Semantics
can change over the period of time. Hence, instead of
For fmmutable-Shared-Files, if creator of file deciares relying totally on operating system, application
it as shared then changes cannot be made in it. The name of
programmer should use protection mechanism to
tan immutable file may not be reused and its contents may
protect the resources created against misuse.
not be changed. Therefore, the name of an immutable file
indicates that its contents are fixed. 5-1.1 4(A) Type of Accesses
Scanned by CamScanner
Sfations, example rena J tS
tl,x
low
evety
Z > * « tevet. For ex >* 01cclion .Gti$;’ d
®<‘). TwrZL by arer-id M d gro up-
implemen
a’fposwfle '° ‘ I“ 8 > by a s2
P e
' - a mh, W,,h llw simil <U1D
s>J “ "«rio n “ -
V J Hence. a USCr haVing re
“d “ of
read p roce tuf
objects. VC t0
P ' y thc
Domain Read
object and rights pair is called domain. Each pair
1
denotes an object and some subset of the operations write
domains.
Domain
Domain 2 Domain 3
Scanned by CamScanner
Operating Enter
Read
Write
Writ*
Read
Read
Read
write
write Execute
te
Write
Read Wn
Read Write
Execute
-, n Sswitching
Fig, 5.1.12 : Matrix nMd *| W ttli<lo”“
what way. This list is associated with each object and called
as Access Control List (ACL). In the Fig. 5.1.13 shown
alt read the file, and also Y has a right to write it. Apan
from these accesses other accesses are not permitted
Y, and Z and three files F l , F2, and F3 are shown. Each
File F3 seems to be an executable program, since Y
domain corresponds to exactly one user, X, Y, and Z.
and Z can both read and execute it. Y can also write it.
Above example demonstrates the fundamental form of
protection with ACL’s. More sophisticated systems are
frequently used in practice. Other than read, write and
execute, many other rights are given in practice. Apart
from, having ACL entries for single user, many system
supports group of users. Groups have names and can
be included in ACLs.
— — — *e System Implementation
dary storage such as disk is designed to hoM s
0 1
file tai an ACL coupled with
Perma? ? The file system resides
n Secondar
file svste* a ° y storage. Implementation of
Ble
ideals with the following.
Scanned by CamScanner
■fr»«tfn8 System ( M U - S e
way fi,es
• Bd
tOre
' management of the & d.
that Storage Management
" K .
h
p' e anagem nt 11 1
H(?vv to ensure that everything Woi *. Ut
logical flip metadata information is carried
Work
' unfailingly ef Metadata c mm
- The file-organization module keeps information about implementation is that it minimizes duplication of
files, their logical blocks and physical blocks. code. Multiple file systems can use I/O control and
sometimes the basic file-system code. Each file system
■ The file organization module can translate logical
can then have its own logical file-system and file
block addresses to physical block addresses for the
organization modules.
basic file system t o transfer. This is achieved by
Limitations
identifying the type o f file allocation used and the
The limitations of layering is that it can bring in more
location of the file.
operating system overhead, which may lead to
Logical block numbers for each file's block is
decreased performance.
numbered from 0 or 1 to N.
Syllabus Topic : Implementing File System
data is stored in physical blocks. These physical
Woch do not match the logical numbers. Hence, a
5.2.2 Implementing File System
Scanned by CamScanner
5-1 S
floOtdir
f file system .
Operating System (MtpSete a
Sector
5.2.2(A) File System Layou t
Boot R eC ' Files and u*
-
virtual file system.
Write
Q-
at operating systems must simultaneous |
Beginning and ending a<
■ _ _ k,; fturtition table All mod ern $ of fi lc sy stems - Thc
- For homogony, every partition begins with a boot for support of network me *------------
block, even if it does not contain a bootable operating one vnode structure for each active node (file or i
system. directory). I
- In future operating system might be loaded tn that Thus, the VFS differentiates local files from remote
block.
ones. The local files are again distinguished as per their
r
Superblock file-system types. The activation of file-system-specific
When system boots, all key parameters regarding file operations i s carried out by V F S to handle local requests
system is read in memory from this Superblock. consistent with their file-system types and even calls the
Usual information in the superblock includes a magic NFS protocol procedures for remote requests. File handle*
number to identify the file system type, the number of are bulid from the relevant vnodes and are passed as
blocks in the file system, and other key administrative arguments to these procedures. The third layer of to
information. architecture is the layer implementing the file system type 01
Free space management the remote-file-system protocol.
To keep track of free disk space, the system maintains The object-oriented principles are used to design VFS.
a free-space list which records all free blocks. It has two modules: a set of definitions that states wb*
I-node file-system objects are permissible to seems to
software layer for these objects manipulation.
The information regarding each file in file system is
kept in data structure called I-node. For each file there Following four major object types are defined by
is one i-node. i- An individual file is represented by i-node object
Scanned by CamScanner
gating Sent 4 . r y .
e01ire
At, file sy stem '
sUP erblock object. rapt U
iadiVidual direct
A" entry , * the Storage Management
b- eDt ry object. " nted b
an open file. In order to access the i-node' s contents, Efficiency, performance, and reliability of the fde
s ste
the process first has to access a file object pointing to | V m depends on which directory -allocation and directory -
the i-node. management algorithms are used. Following are the
algorithms that are used for directory implementation.
The i-node objects do not belong to single process.
Whereas file objects belongs to single process. The i- I
5.2.3(A) Linear List
node object is cached by the VFS to get better
Every file must be opened before it read. User provides
performance in near future access of the file.
path name to access the file. When a file is opened, the
Therefore, although process i s not currently using the
operating system uses the same path name to find the
file, its i-node i s cached by VFS.
directory entry. The directory entry contains the
• All cached file data are linked onto a list in the file s i- information needed to find the disk blocks of the file.
node object. The i-node also keeps standard Every file also has its attributes. Different file
information about each file, for example the owner, attributes we have already discussed. Directory entry
size, and time most recently modified. stores these attributes of a file.
Directory files are treated in a different way from other In the simple design, a directory consists of a list of
files. The programming interface of UNIX define, fixed-size entries, one per file, containing a file name
fcveral operations on directories, for example creati of fixed length, a structure of the file attributes, and
deletion, and renaming of a file in a directory. one or more disk addresses(up to some maximum)
denoting where the disk blocks are. Following
’ system calls for these directory c>P<=rations do «* Bg . 5.2.3 shows this design.
need of the ,.»r nnen the files concerned, u
Scanned by CamScanner
SysteTT1
: Sem 4 - IT) 5-ao
Flit Fte 1 oniry
Attribute*
■era
attributes Entry lor first file
n
B y
findin
attributes
File 2 entry ineffi'
attributes Fite a Bttdbutu Progt
D *1 more
attributes FH Sentry tengiti
of di
Fig. 5.2-3 file
end
Otter fite antrUm nar
to 1
Fig. 5.2J: In-line handling of i Ol)
Fc
, n de!i In this
In this example two file inventory
entries ’ ° ’ directory
Termination of each fi| P ; u *
— ui a tlle 1 5 stored .n .
lg- 5 2 4
shows this design. - - —- — • _____ __ _.apu uiv'unvFU inql
a variable-sized free space i s ’
directory. It may happen that, ne x t file t0
not be accommodated in this free s piiCe ° C ° !S*-
Solution on this issue is compaction
of
Another problem is that a if S ing le (
refers to an i-node
can be used in which maximum 255 characters is The second approach to deal with variabte-kntih
names is to allow directory entries of fixed length and
wasted.
In this approach, fixed size of all directory entries is The drawback discussed above is defeated here- When I
an entry is removed, the next file entered will * a' ! '
section, which begins with length of the entry, and then fit in freed space. The management of heap wilted •
followed by data with a fixed format which are burden here and page faults cannot be avoided as 1C
previous method.
AU the designs discussed, suppons searching
t0 et
directory sequentially from beginning
Scanned by CamScanner
rating System (Mu .
!n» J}
fi
tiding le name
Ual
. deot if directories arefo " Wn
H
jamming the linear list m er k.
U,e Storage Mana merit
' “ ““ - To create hut ta>
to Ca
of out to ’ ui Ching to <he Unkcd
>« o £ ,t
file bus the same name. A f[e , tha ? ' link d
“■'O-Xo » is out “ “ ' Ust is
of the directory fa add(Jd '• » new eotrv "“"J director ter d>
“' s««h
„ «d file « “««hed in di tion of ‘
f0 this file JS released. y
space «>e
teus
The file entry can be marke . * ‘°
o What are th ---------
Assign a special name to fit, , r
-t9r ce FiteT tX 8
"0 ’ 10 " me
®d8
o 1o
iho >r
wn . blank name. ’ '‘ CXan)
Ple an an.
Cf
' OS$
0
A used -unused bit
uu
in each1 ve aCCeSS 10
maintained. cntI flexibility in ‘ which we can
* can
be
6 file, * Op,
»»“'n e * **-*■ of
files. There should
0 Portree directory
► the onofdto »' « space. the
ptIn
may , A Adoption is to copy the last entrv >um and eff « should always allow for the
diiecfo
into the released location and to red D >o the f lles W u r™”" °f S
P“' so that quick
the directory. A linked list can also be ’ ength of USed
majorly in different UpPO,Ud
blowing methods are
tOry
t0 decre -----------— grating systems
ntry the time required to delete a file. ase
Rte
Allocation Methods I
ring . Solution to this problem is use of
m each
directory as hash search is e ffici
JA) Contiguous Allocation
,CIU COrn
sequential search. pare to
<B > Linked List Allocation
5.2.3(B) Hash Table
file
“♦ <c > Linked Ust Allocation
JSin
9 a Table in Memory
~ In this method, a linear l i s t is u s e d t0 stQre
entriesJn addition to this, a hash Jata structure is Z
(D) Indexed Allocation
used. The hash table uses a value computed from the
file name and returns a pointer to the file name in the (E) l-nodes
linear list As a result, i t c an significantly decrease the
Fig. C5.9 : Allocation methods
directory search time. Insertion and deletion are also
quite simple. It i s require to make some provision for 5.2.4(A) Contiguous Allocation
Scanned by CamScanner
U Operating SystemjMu - Sam 4 - IT) 5-22
Directory entry in Fig. 5.2.7 shows that file A starts at 5.2.4(B) Linked List Allocation
block 0 and i t is 3 block king occupying block 0, block
J and block 2. Similarly, file B starts at block 6 and it Q. Explain linked list file allocation
advantaged and disadvantages.
is 5 block long and so on.
Advantages
contiguous allocation. In linked allocation, eacj. ? of
It is simple to implement because, only information a linked list of disk blocks. The scattered disk J'1 it
needed t o keep track on files block is starting block disk can be allocated to the file. The directory C[ ?
and length (total number of blocks occupied). a pointer to the first and last blocks of the fife
For sequential access, the file system memorizes the Creation of a new file is simple. For this, it i s
disk address of the last block referenced and. when io create a new entry in the directory. The
required, reads the next block.
To access block k of a file directly which starts at f r
this file is zero. * °
block i, we can immediately access block i + k. Thus,
both sequential and direct access can be supported by The pointers need to be followed from block to ki
in read a file.
contiguous allocation.
0 0 0 0 00 □ El
Performance i s high as whole file is read from disk in Directory
0 0 0 0 0 □ E] 0
single disk operation. To reach to the first block only
one seek i s needed.
|B B E B B B B B
00000000
13
E] 0EIB B 0 0 0
00000000
00000000
Dimdnry
A 0 3
8 6 S
C 14 B
Disk apace
Fig. 5.2.7 : Contiguous Allocation of disk space Fig. 5.2.8 shows shows linked list allocation for file A
The file A of five blocks start at block 13 and continue
Disadvantages
at block 16. then block 21, then block 24, and finally
When allocated file is deleted, continuously allocated block 29. Each block holds a pointer to the next block.
blocks to the file become free. For new file to allocate, These pointers are unavailable to the user.
these blocks might not be sufficient. If new file size is
small than previously allocated size, some holes - User can see the block size excluding the size required
remains which are not enough to allocate any new file. to store the address. Accordingly, if each block size is
As a result, the disk ultimately consists of files and 512 bytes, 4 bytes are required to store address, then
holes causing external fragmentation. the user sees blocks of 508 bytes.
In some cases, it is simple it is simple to find out space Advantages
is needed for a file to be allocated. For output file this
- In linked list allocation, every disk block can be used
size estimation becomes difficult. For CD-ROM,
which is not possible in contiguous allocation. Hen«>
contiguous allocation is reasonable as all file sizes are there is no external fragmentation except for internal
known in advance. fragmentation in the last block.
Reading a file sequentially is simple.
It is not necessary to compact disk space.
Scanned by CamScanner
ten
fl .-.■•-rating Sy? ? (MU - Sem 4 ,
JU
nta es
ZJ, dva 9
Z
o Z inef6cient to s u Pport a m acce
retrieve to block i t the onemf ss c *
Storage Management
z essibJe W0uld
jj ', ' Direct any d Sk
’ * f Howed
° without
A tfroog pointer can be chosen due
“ evstem .
' 'system Software
' breaka° bUg
« the e ofX'fik d St in8 address (ime
*cr block
a result of w W ch. J r, of disfc
n though file size XT
r
in unking into the ftee- space | i s t . tun, Dlsa
vantage
Ubie
work. ™USt ** *n “*™»y all the time to make it
Index block 15
DisksPace
Scanned by CamScanner
m ( M U - Sem 4 - IT) 5-24
Direct address(12) /
Single indirect
Data
Data Data
Double Indirect -
T riple indirect — - Date Data
Block count Data
Recreance count
Flags(2) '
Generation number
Block size
Extended
attributes size Data
Double Indirect block
Extended Data
attributes blocks
Date
r „ indirect block
= FreeBSD |. node
----- and file struct.
Scanned by CamScanner
ting system (MU s
/'nodes
As
t
is u3Bd
to alfog
a? Store Mana merit
fitdex-node) is Ute s
hicl locks usm
Abates and dtsk address, of , * ' tototu, *hi ch ' ’77 ® *** liat, The disk
s to ftIe
j_ ;<t associated with * ~ _ l — . files blc 2 P e lis or directory
T UCh bl ks
“ totekof
' ° .««-e a neJ r *" ’ “ -
nd dv
ailabiliiy o , ' fcM s
Pacc lira 1. searched for
gets Spbce lf
*■ r e™_ ■ • ’“node located toZ ™ fooad. free space
Th m rc 41
' ° ttoneficial wit h “■ bt f,le sp
«* Im F±“ W F te
' ” d
“ “ «>* « from the
ttoJted list allocation which requ - " ‘“"Pare ; SPS due 10
to gets i„ c | ud ?r “ “» deletion of file is
e
.ration table m memory. ntine <
file *“ W«h«!. " ,rcCSP
*“ l i S*
Qth
h
> the Q. ~- managemant
Fite Attributes
direct
space managemant.
" Address of disk block 0 to
implement ' ---------------------
e
file. arc used SpaCC liSt folIowi
ng two methods
" ArMreas of disk block 1
which
Address of disk bkxik 2
Me1
bod» of free •pecs
Address of disk block 3
fa last disk address i s reserved for the address of a becomes full or empty. Since the bitmap is a fixed-size
ofak containing more d i s k block addresses. data structure, if the kernel is (partially) paged, the
bitmap can be put in virtual memory and have pages of
it paged in as needed,
, Mock addresses. If file grows beyond this limit, this
liSf Advantages
disk address point to disk block containing
diuonaj disk addre sses. ft is relatively simple and requires less space, since it
uses 1 bit per block.
|a
<ty bu» Topic : Free Space Managements
It is efficient in searching the first free block or k
successive free blocks on the disk.
ee Space Management
Scanned by CamScanner
Disadvantages memory. This meth • #(|(Jrcsses „ f, ee blocks
of
4
The whole vector is needed to keep J wRtten to disk In mis meth* . * Actually . the first n-1 of thcse-biZ' *
Otherwise it would be inefficient- flrstf,
occasionally for recovery needs. _omiSin g for ■he 7« t block stores the addresses of %
ftee. The ® As compare d wtth standard
- Keeping bit map in main memo Je for larger blockS
smaller disks. It is no t necessarily P
' r.he addresses of a large number of «
disk size. -Si-""
-♦ 5.2.5(B) Linked List of Disk o __ _ _ 5.2.5(D) Counting
q. Describe linked list of disk block rnetlhod--------------J
15 5.2.6(A) Efficiency I
Scanned by CamScanner
rating System (Mu .
fn a file’s or data
5.2.6(B) Performance
structures.
Accessing the memory is faster with compare to
FiwitfLRU)
accessing the d i s k . For accessing single word, the memory Harfitetta 1
3 Reducing Disk Arm Motton on the bidirectional list and put at the end. In this way,
t L.RU order can be maintained. It seems that LRU
is Arable, treasons are;
Scanned by CamScanner
irating System (MU ■ Sem 4 - IT) 5-28
file system create n* block, it checks if n + l * is the disk into cylinder groups, each with its 0Wn /
Apart from the caching and block read ahead technique inconsistency. F o l l o w i n g are the ways to handle these
to improve performance, other technique is to issues.
minimize the total disk arm motion by keeping blocks
that are likely to be accessed i n succession close to Ways to
each other, i f possible in the same cylinder. In the handle Recovery Issues
Scanned by CamScanner
In order to get the pe rf 06
''"9
information, i t is cach in
,n
updated copy of dir *=Pt in T k di,
Whereas co °" n
’Uon g. .Slcrm Mana
snt
He
by <«* is old copy as cached n
tially written to disk -y info o„ ICe da
A
cssen On
ch - Thii c y 1 arc don P COpy of a11
w
Of there can be loss of co “Pdate is «*« l y
?2 “ X bKI
a ‘"p
also of TO operations Cacl ” •Mneyek? - day 3 „.. ” «"" far files
curn . J. * an d h *
he n, y
cbinc crash. As a res ult ' Wor . anq nc
* ’‘*"*•‘•“ 7. w unai d
‘ y
-'•
y
drones of opened f 1]es " Uion, £ af "' a
in W toC S>
Ieadi the file system i n M - ** lost Th the ’ ia * W b,e * “*
,o « Of7 k 7 Wri "'" ° W tb
'
in '"“ Un g re r ' restore' „ aCk “ P mwli ’ to
'“•
state the actual state of son* s ’ Won ghL-k wil
h the full . . c o m P'«' disk by
$
compare to present in t . "** 's differ _ ,n “lis
t ,rec,
Regularly, during reboot specie °ry „ *hh
e e mi<Wte 8round
sU,e «*‘X2 22*
and correct disk 'neons, s l e n £" tfe
consistency checker p r o g ' * *
8 dn,s
in MS-DOS. "ft/sck in »f
I.
The directory structure data and
a
com ared b the
£ P * » prt>g rams , ? 1(° Cks Of > disk
fl
KCU rs then tries to correct any i n c o r any “■:r—
f .onsj
On . WK match
The disk space allocation and f ree ’
stenci '«( if existh
7 effce ' algorithms can be
algorithms direct the checker proe/’”'*'' '-''’! problem
'becking. The imD | eni , , “* of consistency
to dis
type of problems and how C0' resulted in l KbaMd
SUCC ?™«U«n-or| ( nLd <™T’ °
correcting them. -M The disk file syste joumallng) fi| e systems.
dit SmKturcs for
_ in case of linked allocation, a link i s «'«y
structures f re ,7? . «“>pl K
its next block.
block to its block. ThereforT -*"' 6 My can leads' £ T* f« FCB
reconstruct the file from the data blwfc to failure of system. '"consistent state due to
After this
directory structure is created again ’
10 ab
place whenTise" 2?* ° Ve 5tn,ctures ■»
. In case of an indexed allocation, loss n f , a- incorporated in n~. « 8 "based techniques was not
0PeCab
entry is difficult to handle. This i s because thTdaZ results in " S systems ■ The creation of file
blocks are unknown about the other data blocks X onra Z SX Ur te
“ Wi,hin,heBle
Therefore, For read accesses, UNIX caches directory modificauonof dhretory struck, XoXrTs
entries. On the contrary, for write leading to space flwrefore free
th
these ui counts then
blocks are decreased. If crash occur for all of
these
allocation, or other metadata updating, is carried out
changes can be interrupted and structures can leads to
synchronously, prior to t he corresponding data blocks
inconsistent state. These structures can be fixed after
are written.
recovery. But in such scheme following difficulties
may arise .
*5.27(8) Backup and Restore
The inconsistency may be beyond the repair. The
If failure of magnetic disks occurs then loss of data consistency check made may be incapable to recover
should not be forever. Back up of data from disk to the structures, which can lead in loss of files and yet
° t storage devices can be carried out by system whole directories. In order to get rid of the conflicts, a
human involvement is required. Availability of system
programs. Recovery of any data is now just the
will not remain to the user until the human directs it
ring the data from backup.
about how to proceed. For the consistency checking of
amount of copying can be minimized by making huge size data can require hours of clock time to check.
of information from each file's directory entry. I If log-based recovery techniques are applied to
k** up program i s aware of the time of the last bac. P f le-systetn, metadata updates then the above problems
1
file, then file's last write date in the be solved. NTFS and the Veritas file system use
Scanned by CamScanner
ratii
Stora
5-30 !
These directories then acC e i i «(C)N
A particular directories along
the log-based recovery techniques All changes done i remow clients. so in fact entire directory 'U
metadata are written sequentially to a log- J
-t *.
Thcsc written changes to I he log considered to be fig-
committed. After this the control of execution o
system call can return to the user process which f 4 _rTT’ 1 jiKe *
it carry on execution. In the meantime, replaying o t
log entries are carried out across the actual file system “ ed. Clients can access exported d i r e « ” n
them. When a client mounts a arto 1
structures. Because the changes are done, a pointer is
updated to show which actions have finished an The '
Xw »' NFS **• “ b“ omes ot
which are still unfinished. hierarchy and client can access thcse
Once transaction finishes the execution and committed directory. ehtn
local
nothing bm a circular buffer. In circular buffer writing
peet
takes place from start to end and when reaches at other
end it then continues at the beginning, overwriting operating systems on different hardware, envi * chef
older values as it goes. is heterogeneous. It becomes necessary thai reci
After the crash of the system, there can be no or any interface between the clients and servers be * u
™li
number of transactions in log file. I f the transactions defined.
present currently in log file were not completed to the 1 a
neiu co
file system, although operating system has committed client implementation and guarantee it
it t they must now be completed. The transactions can correctly with existing servers, and vice versa. Up*
begin execution from the pointer until the work is achieve this objective by defining two client- • at
finished so that the file-system structures stays in protocols. The mounting is handled by first NFS d
consistent state. protocol. n
If transaction does not committed prior to system crash
A client can send a path name to a server and request
and aborted then Any changes chat were performed to
permission to mount that directory somewhere in i
the file system must be undone. So the file system will
directory hierarchy. The location at which it is to bt
remain in original state and consistency will be
mounted is not specified in message from client to
maintained. The logging on disk metadata updates are
server.
to the on-disk data structures. The reason is. server do not care for this oi
mounting. If the path name is legal and the director
Syllabus Topic : NFS specified has been exported, the server returns a fife
handle to the client. The file handle includes fields
5.2,8 NFS
exclusively identifying the file-system type the disk
the i-node number of the directory, and secum
on Linux to join file systems of different computers into one
information. *
logical whole. Version 3 of NFS was introduced in 1994
L v wriie
NSFV4 war introduced in 2000 and offers a number of ° vnes m the mounted
di ectory or any of lls subdirectories use the file handle.
improvements over the previous NFS architecture.
i e or directory replication is not supported by NFS,so
5.2.8(A) NFS Architecture
NFS allows a number of clients and servers to share a file systems with system binaries and other files that
hardly ever change.
common file system. These clients and servers can b!
on the same LAN or in wide area network if served
S
'ocated geographically at Jong distance NFS of nfc isC ' 01used.an Clients
d access
purpose,
can send second
messages protocol
to servers to
K
every machine to be both a el
anipu ate dtrectories and read and write files. TM
simultaneously. ‘ent Md a server
Scanned by CamScanner
ifating System (M(j -
on
its Explain the lay Bfed
a-
s.
Fig- 5 2 1 5 shows NFS | ay 22flg_Management
layer is the system-caij layer ''’ .
'«s
«k» °P en - rcad
' “ d
close. Th ? is
’’Yer fa,
is (V
« "ten ittX d C"?
aft Vi
and inspect' the parameter. 'r Pars|„ '"m
te
The VFS layer maintains a m., * "* Ca ‘l
kee
' open elong with a W ' P one ,
enBy for open file. V- node5 1- , '"N fa,
le
local or remote. In case o f H whettl .. V'"»de
fil
is different and is supp,'!”' «, i n C f 115 «
Scanned by CamScanner
5-32
Other using n Paia on floppy disk. Its s,« is 3
pue to read and floppy disk. The di H
System
c
which is ppy is 3W inch. »l
ircd
the location of X i«q° *?
this . uS ed ro cover it. A metal h,
S m
disk cache mechan ' .
write to dWt J K
un i
“ , r,
" ' t
Hardplaa Read /Write window.
magnetic disk. Mag sepa rtby tes
used to c open ed me disk is in a
each partition can Ix n gte abyt * h spce d w** 11
capacity of is at M* u 60 ““"‘"TX d drive. A notch is used to write paC *
_ The spinning ££.£ specd of which floppy ‘ of floppy disk has a size of 51/<
disk is n* use. . cver y second. T js called disk. °t h6r
/Opacity Of 1.2 mb. It is a
5 .3.1(B)M«’9' ieticTapeS
- laln physical structure ot maanetic tape,.
disk can have d flies on
hea
ittencies of several milhsecon K possibility that the
e v e r y t h i n cushion of am h £ surface,
71tb b ta
head may make coot “‘ hat head may damage the
Sometimes it is also possible th
- ’
A fter head
‘ rmUt and have large capacity,
magnetic surface call ed rep | a ced because it r me is slow than that of RAM and magnetic
crash, the entire disk must tie rep Magnetic tape is thousand times slower for
cannot be repaired.
access compared to random access to disk. So <llsk j,
A removable disk permits different „
d]
more preferred secondary storage with compare to
mounted if needed. Removable J o avoid
contain one platter, covered in a plastic cas
damage while not in the disk drive. Floppy “’ sl£s for storing the infrequently used information. It is
inexpensive removable magnetic disks that ave a
used to transfer information from one system
plastic case containing a flexible platter. The head of a another. A tape is kept in a spool and is wound
floppy-disk drive generally sits directly on the dis rewound past a read-write head.
surface, so the drive is designed to rotate more slowly
than a hard-disk drive
in minutes. But once located, the write operation is
carried out with speed equal to speed of disk drive.
Spindle
track t Tape capacities are decided by particular type of tape
drive. Usually, tape storage capacity ranges between
Arm assemby
20GB to 200GB. The storage capacity is double for
Sectors
some tapes which are having built-in compression.
Cylinders Read-write
head 5.3.2 Disk Structure
Modem disk drives are viewed as large ooe-
Platter
Arm
Rotation is the smallest u n i t of transfer. Logical block size is
usually 5 1 2 bytes. The low-level formatted disks can
Fig. 53.1: Moving-head disk mechanism
have a different logical block size, for example
The storage capacity of floppy disk is only 1.44MB. It
is a small plastic plate coated with magnetic material.
The mapping of one-dimensional array of
Data is recorded in floppy disk in terms of in magnetic
blocks is carried out onto the sectors of the disk ' ij
spots. We can transfer the data from one computer to
sequential manner. On the outermost cylinder, in
Scanned by CamScanner
the very first
. a
’Petti J age Mana m
fW conversion of log ical '""<»■ ,D ah
' preorcdcally mto d i s k k n Uln(wr O r <> e r
* ou o ra d ,hal funcl
' O n oveT
ppiriber, a track nurnbor ’"elude. * ,*0. haVi,, erent
8 a On<- ° ndUClOr c
°PPCr cable. It
tor n “ rober withi
" 'hat t, ac . "* '=yl. nd / yli
"*, 24 hil U
“ fabric
IO carry out thia u-a „ sllKK)n ’ •* a
8 netl U re an<
*orki, l '* th® 1>uis ot
g Most of the disks contain s ' '* ason s a . " *»
e
me mapping hides this °'" Mty ’
scotors from elsewhere on tlw \ . ’ti.uy ”• but A
nterfaCC
ers via VO ports cailed as host * by that u J/? - NAS is a
storage-access
SRPCo
~ N AS off ers TCP/IP.
Juted file system this access is via In a tA
N to share a *lc fOT a
” the machinea on a
tached stora ote
# o ge. host called access similar! storage with simple naming and
s ,OCal
> =. * “d
having les. , nther hand, it is i e s s efficient and
st Ormante than TOme
°rage option direct-attached
" ISCS! is th
rCCCnl
protocol \ -attacbed storage
. Local VO ports are used to h
uses the ff lwork protoco1 lo
storage. Different technology is used by
tached '«iy the Sarpro . “| “
5 3
Desktop PC makes use of an VQ bus
-3(C) Storage- Area Network (SAN)
referred as IDE or ATA. Maximum of two drives per One limitation of NAS systems is that the storage I/O
1/0 bus is supported by this architecture. In SATA operations require more bandwidth on the data
network. Therefore, latency of network communication
protocol the c a b l i n g is simplified, SCSI and fiber
increases. This problem can be sensitive in case of
channel (FC) is used by high ended servers and large client-server installations where the
workstations. communication between servers and clients needs more
bandwidth along with bandwidth needed for
SCSI bus architecture has its physical medium as a
communication among servers and storage devices.
ribbon cable that contains 50 or 68 conductors. There
Hence, there is competition for bandwidth during
can be at the most 1 6 devices supported by SCSI on the communication which can lead to decrease in
bus. In general, the d e v i c e s contain one controller card performance.
in the host called as S C S I initiator. Devices also Private network is the example of SAN. It uses storage
includes up to 1 5 storage devices called as the SCSI protoco) to connect server and storage unit instead of
networking protocol. SAN is very much flexible.
targets.
Several systems and storage arrays can be attached to
' The common S C S I target is SCSI disk. The protocol SAN and dynamic allocation of storage can also be
done to these machines.
offers the capacity t o address u p to 8 logical
A SA N switch permits or restricts access between the
each SCSI target. The logical unit addressing is directs
r RAID arcay or Ls and the storage. Consider the example, If host
ite commands t o components or a
„ m n tly have low disk space then SAN can be
components of a removable media library 10 offcr ffl rc StOTa8e l h St
° ° ° —
Scanned by CamScanner
Sterane
SyftobU* Topic : o
0 . techno of dtaksebe
m 5Ho9Mhentol 3 5,m,U.no. S
- .ime to move to - Io -be proper
, last to 57. for a total head movement of
cylinoeia This schedule is diagrammed in
roc for the proper sec,or tO
ZX-I detay "
rotate under the head.
The larger swing from 122 to 16 and then back to i 2o
Actual data transfer time.
demonstrates the problem with this schedule. If
For most of lhe disks, the seek time is greater than
requests for cylinders 35 and 1 6 could be serviced
rotational delay and actual data transfer time.
together, before or after the requests at 122 and 120, the
Hence by minimizing mean seek time; i t i s possible to
total head movement could be decreased considerably,
enhance system performance significantly.
and performance could be thereby enhanced.
Come, First-Served (FCFS) basis then it is not possible 5.3.4(B) Shortest-Seek-Time-First (SSTF)
Scheduling Algorithm
to optimize seek time.
Yet, another approach is possible in case of heavily
loaded disk. When the arm is seeking for one request, Q. Compare the following Disk scheduling algorithms
other disk requests may be produced by other using appropriate example-SSTF, FCFS, SCAN,
processes. C-SCAN, LOOK. M U - Dec 2016. 10 Marks
Several disk drivers keep a table which is indexed by
This algorithm services all the requests near to the
cylinder number. In this table, all the pending requests
cunent head position before moving the head far away
for each cylinder chained together in a linked list
headed by the table entries.
the request with the minimum seek time from the
5.3.4(A) FCFS Scheduling Algorithm
number of cylinders pass through by the head, SSTF
Q.
position.
In our example, closest request to the original bead
position (51) is at cylinder 55. Once we are at
The fust-come, first-served (FCFS) algorithm is the
55, the next closest request i s at cylinder 57. FfOtn
simplest scheduling algorithm.
there, the request at cylinder 35 is nearer than the ok”
This algorithm is basically fair Tm. . .
96, 50 35 is
next. Continuing, we service U*
general doesnot offer the fastest service, ” request at cylinder 16, then 96,120, 122, and
185,
Scanned by CamScanner
System ( M U . Spm 4
,«d » Ration of wme reques(s Reme £ ** arm acts just like an elevator in the building.
may time liaJly jt servjggj while going up and
, a. “”7 “ lh „ *
ueStS qUeue for en
' e tw° " ““ - linden, j6 and reverse the direction towards down, it service the
' and white servicing .he requesl from quests on this way. Therefore the SCAN algorithm is
>6 arrives. a
lso called as the elevator algorithm.
.-st-'-:™—-:
‘ another request close io 16 .
“ arrive,
g
jn t oO
C u lu M
l 1 s
consider the same example discussed above.
Before proceeding with SCAN to schedule the requests
on cylinders 96. 185, 35, 122, 16, 120, 55, and 57, the
a continual stream of requests near one another
direction of head movement should be known along
arrive. causing the request for cylinder ) 8 S lo
with the head's present position (5 1).
indefinitely-
I f movement of the disk arm is towards direction of 0,
„ e e 9 6 . 185,35. 122, 16. 120,55,57
the head first will service 35 and then 16. After
(he disk.
Scanned by CamScanner
otora
5-36
20
Queue - ~96, ii w
M,. M . i s j e . ' - 56 ' 57
■* (fee.
M U - Dec 2016.7b”
C-SCAN is called as Circular SCAN scheduling and it is a variation of S C A N . It offers a more uniform wait time
service
any requests on the return trip.
The C-SCAN scheduling algorithm essentially treats the cylinders as a circular list that wraps around fro k*
cylinder to the first one.
Head start at 51
16 35 5 1 55 57 96 120 1 2 2
0 ------- h 4- 4-
185
4-
Scanned by CamScanner
.Storage Management
165
rBt B,BOrit
closest reque -t hm always handles the
J Previou. reject was °° Zea S* “ “*
pending requests, in FIFO order, is , Tow
86 147Q «lme , « 20 _ 20) + (22 _ _ W)
f774,S48.1509, 1022, 1750, 130 Starting f rom the . + (10 - 6) + (6 - 2) + (38 - 2) + (40 - 38))
position, what is the total distance ((in cylinders) that ’ 6 msec = M • 6 msec = 360 msec
jetfisKarm moves Io satisfy all the pending requests, for
nearest requestsA)in8° increasiog
nearest
nlh
™ ■ Elevator
(dKreasing) algorithm handles
« requests on the way. Afterwards the direction is
SCAN
I, FCFS reversed.
*5c*rtk)n : Total time: ((20 - 20) + (22 - 20) + (38 - 2 2 )
Tbe FCES schedule i s 143, 86, 1470, 913, 1774, 948, + (40 - 38) + (40 - 10) + (10 - 6) + (6 - 2))
(M1022, 1750, 130. The total seek distance is 7081. * 6 msec = 5 8 * 6 msec = 348 msec
He SCAN schedule i s 143, 9 1 3 , 948, 1022, 1470,
Example 5.3.3 MU - Dec. 2014. 10 M a r k s
1503,1750,1774, 4999, 130, 86. The total seek distance is
Suppose that a disk drive has 5000 cylinders, numbered 0 to
4999. The drive is currently serving a request at cylinder
i»n(* 5.3.2 143, and the previous request was at cylinder 125. The
queue of pending requests, in FIFO order, is 86, 1470, 913,
• requests come in to the disk for cylinders 10, 22, 20, 2,
1774, 948, 150971022, 1750, 130. Starting from the current
*; Sand 38. A seek takes 6 msec per cylinder move. How
head position, what is the total distance (in cylinders) that
!<tt
Mek time is for Closest cylinder next algorithm? the disk arm moves to satisfy all the pending requests, tor
"tyam is at cylinder 20. each of the following disk-scheduling algorithms?
SSTF C SCAN d L K
FCFS & ' °°
f||
*Come, First-Served algorithm accepts requests . OSCAN I.C-LOOK
Scanned by CamScanner
Stora
jAaruv..
5’38
Solution :
Scanned by CamScanner
ting system (My . s *
:r 507 = 8 9 8 . ( 1 3 5 0 - ,
86)
-«- 3 o)
*> 143, Sto
Management
3
= 150 ~ ' ’0)
ftead movements are :
8STF 3
SCAN : The SCAN schedute is 1 J s ***>>: >-OOK «. SCAN 5. C-SCAN
S5
> M35<M5OO -’3O,86, 50.0,
13
1 ( f jves(15S- °) = 25,(13o_ 86) = 1
,(M
= 36-(5O- 0 ) = 5o '5O) i
- aX 1
L8 1777
' <M8,1O22j75<) ' !30 -
(948 - 0) = 948,(1350. * = 63. (1470 -&0) 1390,
W2 t - ( 1 4 7 0 - 913) = 557,
(1500-1350) = 150 '
(J 777 - 9 1 3 ) - 864. (1777 -948) = 829,
Total head movements are : ( 022-948) = 7 4 , ( 1 7 5 0 - 1022)
= 728,(1750 - 8 0 ) = 1670
Otal
- SCAN : The C-SCAN schedule is i 5s movements are <
c 13Q
1 + 1670
JO,0,4999, 1500, 1 3 5 0 . 9 4 8 . 30,86,
~ 6125 Cylinders
jt gives ( 155 — 1 30> = 25, (130 - 86) = 44, (86 _ J0)
2. SSTT:
The SSTF schedule is
143,130, 80,913,948, 1022, 1470, 1750,1777 .
(50 - 0) = 50, (4999 - 0) = 4999, (4999 - 1500)
11
gives (143 - 130) = 13, ( 1 3 0 - 80) = 50,
= 3499,
= (913 - 80) = 833,
(1500- 1350) = 150, ( 1 3 5 0 - 9 4 8 ) = 402.
(948-913) 35,(1022 - 948)= 74,
Total head movements are : ( 1 4 7 0 - 1022) 4 4 8 , ( 1 7 5 0 - 1470)= 280,
( 1 7 7 7 - 1750) = 27
Cylinders Total head movements are :
- C - L O O K : The C - LOOK schedule is 155,130,86, 13 + 50 + 833 + 35 + 74 + 448 + 280 + 27
50,1500, 1 3 5 0 , 9 4 8 = 1760 Cylinders
Itgives (155 - 130) = 25, ( 1 3 0 - 86) = 44,(86 - 50) 3. LOOK: The LOOK schedule is
= 36,(1500 - 5 0 ) = 1450, 143,913,948, 1022, 1470, 1750, 1777,130, 80.
( 1 5 0 0 - 1350) = 1 5 0 ( 1 3 5 0 - 948)= 402. It gives (913 - 143) = 770, (948 - 913)
= 35, (1022 - 9 4 8 ) = 74,
Total head movements are :
(1470- 1022) = 448, (1750- 1470)
25 + 44 + 3 6 + 1 4 5 0 + 1 5 0 + 402 = 2107 Cylinders
= 280,(1777- 1750) = 27,
(1777-130) ~ 1647,(130 - 8 0 ) = 47
1350,1500
Total head movements are
Itgives (155 - 130) = 25. (130 - 8 6 ) = 44, (86 - 50) 770 + 35 + 74 + 448 + 280 + 27 + 1647 + 50
— 36,
= 3331 Cylinders
(948 - 50) = 898. (1350 - 948) = 4 0 2 .
SCAN: The SCAN schedule is
(1500-1350) = 150.
,, 913 948, 1022, 1470, 1750,1777, 4999, 130. 80.
Total bead movements are :
It gives (M9113 3 - 143) = 770, (948 - 913) = 35.
25 + 44 + 36 + 898 + 402 + 1 5 0 = 1555 Cylinders ------ (1022 - 948) =
E n| 5 3 7
’* * - - . numbered ° t °
Su 0 1
PP°se that a disk drive has 5000 cy *■ a t cyl»nd0 r
The drive is currently serving a ----------
Scanned by CamScanner
-Storage
24
160) *=
mentsare:
System (MUjjem d1 n 0>ov<=
tratii O) = 4* 69
’ Total)** ' 1 + 20 + 132 .
1 3 16 + +
(4999-1777) = - + 3
10 + »
50
(130-80) =
100 5
' /’i00 90) = 10 - (90 - 58) = »•
= 9775 Cylinders iVe9<
'•« ‘; 55) = 3. (55-39) =16.
(58 -
C-SCAN : Tbc C-SCAN scbedi11
t
4999, o t 80 t
(39 _38) = 1 , ( 3 8 - 1 8 ) = 20,
143, 913 , 948. >022, 1470. 1750.1777.
(18 -0) = 18, ( 1 5 0 - 0 ) = 150,
J30.
770. (948 — 9 1 3 ) 3 . ( 1 6 0 - 1 3 0 ) = 1 0 , ( 1 8 4 - 160) = 24
It gives ( 9 1 3 - 1 4 3 )
(1022-948) Total head movements a r e :
(1470 - 1022) 2. <1750 - 1 4 7 0 ) = " 32 + 3 + 1 6 + l + 2 O + 1 8 + 1 5 0 + l o+ :
1777) = 3222,
( 1 7 7 7 - 1750) = 27,(4999-
(4999 - 0) 4999, - 284 Cylinders
50
(80-0) 8 0 , ( 1 3 0 " 8°) = IOOK- The LOOK schedule .s
I00 . 90, 58, 55. 39. 38. 18, 150, 160, 184
Total head movements are :
+ + 80
It gives (100 - 90) = 10.
+ 5 0 - 9985 Cylinders (90 - 58) = 32,
(58-55) 3. (55 - 39) = 16,
Example 5.3.8 . .
(39 - 38) 1 , ( 3 8 - 1 8 ) = 20,
Suppose that a disk drive has 200 cylinders, number
199. The initial head position is at 1 00 th track . The que ( 1 5 0 - 18) 132, ( 1 6 0 - 150) = 10,
pending requests in FIFO is 55, 58. 39. 18 90, 160. 150, , (184-160) = 24
184. Calculate average seek time tor each of the o owi
algorithm, Total head movements are :
Scanned by CamScanner
fl ratify System ( M o
(184-18)
(38
(39-38) -181
M55. 39
(58-55)
head movements . ' S8
) = 32
' 2 . *4“ * -**-**■ 2®ss«m«™ tent
[11al
hc.| *l> “ J. <91 _ b * . ,
— 7
5.3.9
that the head of a
5
0 1 19 CU,TB
red *° "' 'W eenJ'* **"’ trtu ,
n
, a nd has just finished a req U B S t 9 a re, ta. 10 M a r k ?
’ ests is kept in the FIFO ord ** 12 5 .
,or 20 S ,M
len
cj wi s ' 147.
to,al numher 9tti a™ 'SCAN. C-l,ook r eduUng It carried out
L is <>' Heed
thes e requests for nee
to
SSTp Sfk i
.igtxi ®' eduth
ing
fCFS 2 SSTF 3
‘ E<eva
tor n,.o ***>»*
1
utloh : ----------
102 10)
> ‘75, 13Q
[t gives ( 1 4 3 - 86)
57,(147 86) =6l 262/9
(147-91) C’SCAN , “ = Average 29.11
56, Ule b: l00
‘20, 110 ’ 41, 27, 10, 186, 147, 129,
(177-91) 8 6 , ( 1 7 7 _ 94) = 83 ( 100 - 641+ j . . ..
(150-94)
5 6 , ( 1 5 0 - (02) = 48
( 1 7 5 - 102) =
73,(175 l
" 30) - 4 5
" 3 + 14 + 1 7 + 1 7 +39+ 18+9+10 = 342/9 = Average 38
Total head movements are :
SthedUlB 10 l10 120 l29
27
* ' t 41, 64 °> ’ ’ > 147 ’ 186
’ 10,
Scanned by CamScanner
Stora
1 4
tting System MU - Sg” ~
Total movements t
23
9+5+20+ 100+.1O+.30 *
5.16(A) Disk Formatting Il partitions the disk into one or more groups oi
cylinders. Each partition is treated by OS an
' magnenc recording raateriaI
then
“ is
- a P' a «- of a separate disk.
cannot store data. The surface needs to be divided Logical formatting. That means creation of
m seem so that disk controller is able to perform reaJ system.
rcad
and write operations.
In order to increase the efficiency, file system gr*
ock-s in chunks called as clusters.
Scanned by CamScanner
System (MU - Sem 4 . ,
pje full bootstrap program is more sophisticated than The performance of CPU has been rising immensely
over the past decade,, approximately it is getting
[fie bootstrap loader in the boot ROM; it is able to load
increasing by 100 percent after every 1.5 years. On the
the complete operating system from a non -fixed contrary disk performance is not increasing with this
location on disk and to start the operating system speed. Now days average seek time of the disk is near
execution. Yet, (he full bootstrap code may be small. about 10 msec, which is very less compare to average
seek time of 50 to 100 msec on minicomputers in the
5.3.6(C) Bad B l o c k s decade of 1970
Failure of the disk can be : If in any other industry, performance is enhanced by 5
- Complete, means there is no way other than replacing to 10 percent in two decades, it would be considered as
the disk. Back u p o f content must be taken on new disk. great achievement. However, in the computer industry
it is an discomfiture, As a result, the difference between
- One or more sectors become faulty.
CPU performance and disk performance has grown to
- After manufacturing, (he bad blocks exist. Depending be much larger in due course of time.
on the disk and controller in use, these blocks are
In order to get faster processor performance, parallel
handled in a different ways. processing is being used to a greater extent. Over the
If the disks are with I D E controllers then these are years people thought that parallel I/O might be an
excellent scheme as well. In research paper of 1 9 8 8 ,
wple disks. In these disks bad blocks are handled
Patterson et al. recommended six specific disk
"snuafly. For example, the MS-DOS format comman
logical fonnatling md. as a part of the process
Scanned by CamScanner
Storage M a
I hhJ raW a 1
k
°f
ttie
the above
erne is that, in
---------- drives needs to be rotaJ Si
Scanned by CamScanner
r T Operat g System (Mp
hnmized and ic T*
,
>«i ate 'S o f drives (regardless / F
w
jrivest the overhead is j Q d at 7 Kh a 7***
t Up of .he controller. as ® Per*. »tgt
jrwksum every bit B n>u „ • ft ai "d ,,
Pcrf
hAJD level 3 le deo,™'. »n» > l v . * >
a simpler version of jn p ' p.M.n.0, ,
te
d Ove
rx ’
r
• hth
Stripe
00 Strip 4
L pi
s rip 5
onc Strip A
k pa
1W 8
U1
0
f
0Ur Strip o
this
Lsthp4
3
in strip a
of
of fl raid
J level 1
P
te Bit 1
Bit 2
(C) Bit 3
Bit 4
Bit 5 BftQ
Bit 7
RAID level 2
L at 1 Bit 2
Bit3
Bit 4
RAID level 3
(0 [Strip sj [Strip 9
[Strip 121 L Pt l
P16-19J Strip 161
Scanned by CamScanner
Storage Managgw-
driv« and again operas wil J* rA(D level 4 at the time failure occurred prior to lh
W
consider individual words P rA(D | e vel T „«l '“ , V d , so the previous data value, '
Sl
demonstrated in Fig. 5.3.7(e) 15 an e X tm .■-L- write
0. and here a strip-for- P fc k bytes.
lW
disk ren 311
dri „, Forin!lm x. if .he tens-h > on dl tbe ■ of block, failure happens then S ysltRb
wrl
EXCLUSIVE OR o»e • «« „ sBip of If during * and call a recovery procedure
strips together. This operation results should dcLeC ‘ b llock to a consistent state. F Or
length k bytes,
reinstate the physical
Scanned by CamScanner
<uB. « ' s a sma11 P!astic
D’ 13 is reco 'ded in n n C a e
° ' d v P B=Se5 41?
✓ spots. We can tra in te ic I
X r t0 other using floppy the or
M n
. ° T" ieni
S*. *ll ot vwk capacUy
C()j SC(l I
, All above disks arc c a l l e d read-write disks. In contrast, This section explains how operating system carry our
wriie-once, re ad - m a n y - t i m e s (WORM) disks can be | itsjob when removable storage devices are used,
written only once. C D - R O M and DVD-ROM are the Application Interface
eumples of R e a d - O n l y d i s k s on which prerecorded
Operating systems handles removable disks in the same
data is available. Technology used by these disks is
maimer as they do handle fixed disks. It is necessary to
similar to that o f W O R M d i s k s and they are very format blank cartridge when it is inserted or mounted
durable. into the drive. An empty file system is then generated
Tapes on the disk. This generated file system is used just like
a file system on a hard disk.
Magnetic tape stores large amount of data compared to
The handling of tape is carried out in a different
Wai or magnetic disk cartridge. Although disk drives
manner. Initially. OS treats tape as a raw storage
tope drives have same transfer speed, random
medium An application does not open file on device.
*cccss on tape takes more time compared to disk see
An application opens the whole tape drive as a raw
drive is more expensive than disk drive. But
Scanned by CamScanner
Storage Manage
Mana9em
application untii 0*
7
exits or closes the tape device. H„ ric jukebox facilitates for changing
A m
As tape drive is presented as raw device. OS does no 1 cartridge in a tape or disk drive
offer file system services. The application most make a
"““L intervention. A hierarchical storage sy5tem
decision about how to use the array of blocks. * hU
X the storage hierarchy beyond main memory
application decides its own rules for organizing a tape, W1
' dary storage to include tertiary storage. Tcrtlajy
I a tape full of data can usually be used by only the
storage is implemented as a jukebox of tapes w
program that created it. For example, although a
removable disks. This storage hterarchy is
backup tape holds a list of file names and Hie sizes cheaper, and slower.
followed by the file data in that order, it is not easy to
use the tape. The normal method to include tertiary storage is te
widen the file system. Small size and frequently USM
seekf ). Instead of seek( ), tape drive uses locatef ) files resides on disk, whereas large and old files wWcll
operation. The locate ) operation of tape is more having no active use is stored to the jukebox. In
accurate than seek( ) operation as tape gets positioned
to correct logical block instead of entire track. Many ;er
number of tape drives supports read-position ( ) holds space in secondary storage.
operation that returns the logical block number where
the tape head currently exists. Many tape drives also installations with large volumes of data that are used
support a space( ) operation for relative motion.
rarely, at irregular intervals, or sometimes. Existing
File Naming work in HSM comprises extending it to offer full
- On personal computer, file name contains name of the
drive followed by path name. In case of removable data go from disk to tape and back to disk, as required,
disk, it does not mean that if drive containing the but are deleted on a schedule or in accordance with
cartridge at some time in the past is known means how policy.
to find the file is known. If every removable cartridge
had a unique serial number, the name of a file on a 5.3.9(C) Performance
removable device could be prefixed with the serial
Tertiary ’Storage performance is measured in terms of
number, but to make sure that no two serial numbers
speed, reliability, and cost.
are the same would require each one to be about 12
digits in length. It would then difficult to remember 1 2 Speed
digits file number as a file name.
Bandwidth and latency arc two metrics to measure
In case of writing the data on a removable cartridge on
one machine and then use the cartridge in another
machine, the problem will become more complex. If is steady is the average data rate in a huge transfer-
both machines are same and with same kind of
spectfically, the number o f bytes divided by the transfer
removable drive, then only trouble is to find
time. The effective bandwidth considers the average
contents and data layout on the cartridge. If both
Scanned by CamScanner
It for fastest; it js
e r
per 30 °
y is second melrics ,0
Z’ 8
* 1
With
Storage m. ment
' tf hich tok performance is ft Pa _ inr
'1 ec ,. “* tow CM1
>s in operation, then “ ’ to *» In ot
many removable
58
sidcraWy r ffaremo i late „ c y *Mf «***
s
* has ; dncs
. cost ncr m .
£balg ed. then dnve must stop 5pj I. n £ ,M
’"’ttoitad. ?°' h> more °*
ann !S required to s w i «be has this i m D r n lhlul four
orders of
then the dnve shou!d spin * ** £ - No only th for memory
N ftntt
prim ° 8 Ude.
11* *"“>**! tit **
b> ract
ont-access time within one longer
As
£
n
" °' ouoTtt? mwt co“ ,y °'ra <i‘’k
pitching disks in a jukebox leads . re * ' *"«•• more megabyte baa
a con
W h performance penalty. >ParatiVcl
p
'tSAtfove Jre " •
jlie robotic-arm time is same f or d - , drive i s 2Oin ° * f lape
cartridge without
Befo ,0
etching the tape, old tape requires re /’*' * small- and med ** n “”y sa
™ • A» » result,
S 11 Ub ies ha ; a w
ran * e -iected ' The d n « required fo r J ng
it "W cost than disk™ ™ '" «h “
Opera landKk
sb out 4 minutes. Several seconds are "™ is — - *yste™ With equal capacity.
Uired
loading of new tape in drive to get ? after **** S* **"'* Topk !
Swap-Snnce Munagement
,0
prepare for I/O. In case of perfomtanc e’o
drivcs
a jukebox, the bandwidth and latency I t
rcasonable
Q.
Bul seem to have a terrible bottleneck °°
olft'n «*ap Space in detail
r Reliability
e agemen lo |evel
the opera btl g ™ '" *- job performed by
, Reliability is important metric tn
10 hold all >h/„. ™ S ma
y » •>« sufficient to memOT
n
performance. Removable. magnetic di sks “’fcasure
„ e ,o the
disk Rnarp J*** 5* 8 simultaneously, virtual memory uses
S aCCCSsing the disk ,s
extent is less reliable than are fixed hard dixk, > case
"* access ng the
k mam memory, using swap much slower than
space considerably
uisKs. in
s
Of removable disks, the cartridge is probab | y TOre system performance. The main aim towards the
exposed to damaging environmental conditions; for Jign, and implementation of swap space is to offer the
best throughput for the virtual memory system.
example, dust, changes in temperature and humidity,
and mechanical forces like shock and bending. 5.3.10(A) Swap-Space Use
Optical disks are very much reliable. In this disk, layer The use of swap space is carried out in different ways
storing the bits i s protected by a transparent plastic or by various operating systems. The way operating
system uses swap space merely depends on the type of
glass layer. The reliability of magnetic tape depends on
the memory -management algorithms in use. Such as,
type of drive and it differs largely. Some low-cost Swap space may hold complete process image, with
drives wear out tapes if used for few number of uses . code and data segments.
Whereas, some other type of drives permits millions of Paging system may store the swapped out pages from
reuses. The magnetic-tape drive head is a weak spot main memory. The needed size of swap space differs
based on the amount of physical memory, the amount
compared to magnetic - d i s k head.
of virtual memory it is backing, and the manner in
T
Cost which the virtual memory is used. It can range between
few megabytes of disk space to gigabytes.
It is better to keep sufficient amount of swap space that
consider. Removable media lower the overall storage is required. Otherwise operating system will be forced
cost. Though it is somewhat expensive to ere to abort the processes as system may run out of swap
removable cartridge, the cost per gigabyte of removable space There can be chances of system crash due to its
running out of swap space.
storage may well be lower than the cost per gigabyte o
a hard disk. The reason is, the cost of one d---------
Scanned by CamScanner
Storage
Syllabus Topic r 1/0 systems and device Y has a cable that plugs into device Z, and
dif,eren Parameters
SZ. ' distinguish 1/0
Basically i t should have lo igsu . ' Devices can be disti
«ces, catch i Bfcmipts . J, the mguished with respect to following
parameters.
Provide an jBterface » should 1. Data transfer rate
3. Control r - * c
2- Device application
plexiiy 4. Data transfer unit
5. Data
representatiion
Errors
Scanned by CamScanner
I I
1 l
<«pp ue
’‘‘ o n ! T h e a
PPHeati on * tho -1 o,
dev,CeS VaneS
n-dUh | ...... Management
“ the tom „
> complexity : The c °f Por ln
«C ' “Plex C* Wrtal Pon
* cW
« “ b '’ u >
tbe devices are also varies. qui
■ “ “ ni ‘ hi Thc '"‘“•faring of A °f theT “ the X7 my
' hC, * i " 8 '
of by eS
, ' “ Characters or >n l a r . ° data
Op h. .
1
r«Pr€sentfltion : The
d a ta f
6
nCodil
, varies different devices. >8 me tl _
' rs = Thc
characters of errors v
PWatei re i s
« ten are ,o
«’<> <Wn The
. . «— •
, g e t o another. ** bro V n
to es 4n “toe of t h e . °™ > 1 '»F1F0« bytea.
aU
chitB
« the M ““
Zsj"»fo Topic : Overview MO - further ttan
< I/O Hardware of ir
’’ sem m ChipS qan store 8Cv
W and output a f ° eral bytes
’ /Device Controllers t0
- tOre
a small bi™ / FlF0 chip WOrk like
buffer
ntil thc or
those dau “ host
* Kput/outiw' U "“ S COnsist of a
mechanical com
5 4
' •» ele " c0
"~t. A co
- Wolling
section of electronics
Dradevice-
that can operate
P
° R’
r
a
,s
a
h US ,
i
A serial-port controller is an example of a ■ Prol0C0 fot
Tc' ' totoraction between the host
ice controller. It is a single chip in the comput ’T, handshak- U nlricate
Shaking notion is simpk .' ’ but basic
controls the signals on the wires of a serial port. The controller indicates its slate through the busy bit in
The implementation of SCSI bus controller is done status register. (Recall that to set a bit means to
most of the time as a circuit board which separately *nte a 1 into the bit, and to clear a bit mean to write a
plugged into the computer. 0 into it.)
When controller is busy in operations, it sets a busy bit
It normally includes a CPU, microcode, and some
This busy bit is cleared when it is not working and
private memory to facilitate it to process the SCSI
ready to accept the next command. The host signals its
protocol messages. The S C S I b u s controller is integral
desires by means of the command-ready bit in the
part of the some of t h e devices.
command register.
Total four registers are present in I/O port. These are This command-ready bit is set by host when a
as follows : command is available for the controller to execute. ■
o Status register For this example, the host writes output through a port,
Scanned by CamScanner
Storage
5-52
ET Operating System
X xx g «. inten
* h
* B
* j contro|P W ith the ‘0 manage 0,6
°f flow
50 deWce I( sh
out poij ing ajj (he /, ' °M do
oae deWCeS t0
Consequently, the kem i
raised the int emip( rve which read that com
is implemented bv ! Pletes a disk
y apairof
The i/o statu • interrupt handlers.
,Ce
interrupt
Scanned by CamScanner
■rfinq System ( M U - s .
U raises
°’ ““ « low
d W<Mfc
> *
_ user le *»< 1/0 « <*>mpleted . " P1 *>
by C Pyin8 da,a fr ,he
, ° °m ko int
Iic81iO n space. It then invoke, .J"" Mera'S
£ P n he 'hllads """h** «»> be celled
aJ >plica»°
on the ready qUeue *hed ull . r “ 'he
n,n nx
fundamental interrupt meek . <Wew , adOu T “ lnKl ™°' ,c
interrupts the routine or program, which is running Information is transferred in the form of bytes or words
presently interrupts and an interrupt service routine and for these it must supply the address of memory
location and every bus signals that control the data
of the devices and called exception or signal or trap transfer. Communication with a device controller is
handler in case of software interrupt. handled through a device driver. Device drivers are part
of the operating system.
Processor executes the program, called interrupt service
The operating system provides a simplified view of the
routine or signal handler or trap handler or exception
device to user applications (e.g„ character devices vs.
handler or device driver, related to input or output from
block devices in UNIX). In some operating systems
the port or device or related to a device function on an
(e.g., Linux), devices arc also accessible through the
interrupt and does not wait and look for the input ready /dev file system.
CPU S
“ h7h -d or write. These
of registers dw P Kgistelj a byte .
an interrupt, and the ISR called. The ISR n»« on a
renters compn * control registers .
Wte interrupt stack only if the count register, ands gi
Otherwise, the ISR stack frames are pus
of the interrupted thread.
Scanned by CamScanner
5-54
=*■"«■*> Mary,-.
- S e m 4 - IT)
1 CPU DMA
preujraiTy<
CPU IM DM*
to the I/O device, the unit of data or information
transferfin terms of byte or word at a time), and the
total bytes to transport in one burst. L
Without DMA, let us see how disk read occurs. 2 DMA iwganka
Intamipl Mwn
Initially the controller reads the block from the drive (tor*
3
Dwth it
Scanned by CamScanner
System 1MU - s 6rn
1 Of operation :Device
C nd to
“ ° a
01 1
s* * kgab
ge»d •wr’1*’ «»d only, Or „ Man rrt
system call that maps a file into memory returns - The setting can be for generating interrupt once or to
repeat the process to cause periodic interrupts. When
' the virtual memory address that contains a copy of the
process is al the end of its time slice, it should be
file. The real data transfers are carried out only when
preempted.
required to satisfy access to the memory image.
The scheduler uses above method to generate an
As the transfers are handled by the same means as that
' for demand-paged virtual memory access
used
services. Q.
VO.
W) Network Devices y ioten ns
Scanned by CamScanner
5-56
4
[ Toperaang System (MU - '
guested. >e cal | requests a transfer that wi|'|
o. , Explain issues related Io performs 0US
as ynchr°" its entirety but w i l l complete at
system. _ nrmcd m
g
The execution of the application e cuting ‘he
issues a blocking a system c . b|ocking it will ■ Tropic : K.mel I/O Subsy.teTT
application was in run q u * ue -
move to wait queue, .
Kernel VO S ufasyStem
After the system call finishes, the app ica e( j to
provided
moved back to the run queue, where t
resume execution. Q.
related to
- When it resumes execution, it w i l l receive the
Following are
returned by the system call. The physic
performed by VO devices are usually asynchronous
rei
they take a varying or unpredictable amount o f t i m ices provided
However, most operating systems use blocking system
calls for the application interface. This is because
(A)I/O Scheduling
blocking application code is easier to understand than
non-blocking application code. (B)Buffering
Apart from blocking VO, some of the user-level
processes require non -blocking I/O. One example is a (C)Caching
user interface that receives keyboard and mouse input
while processing and displaying data on the screen. mJ (D)Spooling and Device reservation
Overlapping of execution w i t h VO can be achieved by (E) Error handling
writing multithreaded application. While some threads
cany out blocking system calls, at the same time others
Fig, C5.13 : Services provided by kernel
carry on execution. The Solaris developers used this
technique to implement a user-level library for 5.4.4(A) I/O Scheduling
asynchronous I/O, freeing the application writer from
It involves deciding the good order in which I/O
that task. Some operating systems provide non
requests should be executed. Scheduling can enhance
blocking VO system calls.
the overall system performance. Processes also shares
If the call is non-blocking, then i t does nut stop the
the device accesses in fair manner due to scheduling.
execution of the program for an extensive time. It
The average waiting time for I/O to complete also can
returns promptly, w i t h a return value that shows
number of bytes transferred.
be minimized.
The substitute to a non-blocking system call i s an There is a wait queue of requests maintained for each
asynchronous system call. An asynchronous call device. The I/O request of the application is placed on
returns immediately, without waiting for the VO to the wait queue for that device when application issues
complete. The application continues to execute its blocking I/O system call. All these requests are then
code. arranged in a manner such that, the overall system
The completion of the VO at some future time is efficiency and the average response time experienced
communicated to the application, either through the by applications will be improved.
setting of some variable in the address space of the
Operating system tries to give equal service to all the
application or through the triggering of a signal or
applications. Delay-sensitive requests may be serviced
software interrupt or a call-back routine that is executed on the basis of priority. For asynchronous I/O, kernel
outside the linear control flow of the application.
should keep track of many I/O requests simultaneously
As compared to asynchronous system calls a non- Hence, the OS might attach the wait queue to a device'
Wocking readQ returns without delay with whatsoever
status table. This table keeps the entry for each VO
device and its management is carried out by kernef
Scanned by CamScanner
slatc of lhe dcvict
** <»**!■ “""‘ouin.
i*' device * busy in proe ess .
ff * tyt* and
°’ hCr parameters wil '
I be
t icn ""brefr ' i a n n e . ' ' n < tai per need, and the
t*" enW lha
‘ device. Sched, "*'*™™.T W . « h Un e i , rOT
E
........ of the
cha
f itnp ' rov ng
f* °nnance“* the rf SVSte,
" Ott.« “» S w’rhT™ ™'«’
n0 „, ““ I, t,t Bt
< i0 main memory or on disk via teeh?* to
’ '** t»t then, a " (ul1 - ,h =m i’
Peril'S' caching ’ and s
P°°Ung. ca]leiJ w
M kcr
i buffo,. UUori
over this is to have a
fort Ftf5t bufttf
uflerin9 'l has em * 7 «p. but
.4.4(0) B htn the P
' lhe !iecond onc
is used.
m
to the ’ S UP ' * “ liable lobe
Co h,le
the Pied to Uscf ‘ the second buffer is being
' P raduCCr and
consumer of ? ata" 1 ' stsm ’>ch C
second reason for buff cring ream. character y n .l- ' jC F' rs one can be used for new
nt two
fcr sizes of the diffe rent dcv . alternatively, . buffers can be used
dK W
similarities are particularly COmmo „ s
‘ Such ' i 8 aee:e I™“ " “ P ', ' d to user space,
S
Scanned by CamScanner
Storage Mana
corresponding spool f
icd b y spools Kernel kccpS different in-kernel data struct
nLS
cO mpo oDen -file table structures, kernel Uses
system to the poorer b
* agcm eI .l of *t»°“ n
« just Hke the r , dif&rcnt VO activities like netw
precess is responsible for ting system*. m any structure - vicc communications etc.
Zme openmag connections, cha _______________________________
is managed by e n m - k e n t d 1/0
____ . . lrfa ,.itlJiin*nil Requests t0
opera K R ,
For this purpose. “J d ,y SBnia dmini*ire ’ °
interface that allows users j ob s prior to
display the queue, to whjle lhe printer is Transforming I/O Requests to
those jobs print, to suspend pnm g I
serviced, and so on. he|pfu ||y Hardware Operations
_ es is transto,m ,o hard
Explain i® RWU ’ *are
the I/O requests
operating systems operations.
8 SyStem n,nning m
completes the I/O operation.
ehZ JJeth ' “ ° nitOT
3. If required data is in buffer cache then a physical
not
trie
— I/O requested.
must carri
** ed out. The requesting process is then
Scanned by CamScanner
C0*1
lee
ft»e
Driver end
The address space of the requesting proc ,
data O r code from kernel and process gets '’ K * iVes
a ferred
from wait queue to ready queue by kernel. “
F g
As process i s i n ready queue, it i s now ' ‘ SA2 : The
STREAM structure
When process gets CPU, i t resume., execution at £
S! aVaiUble llBn
Z" ”“ “ ““ «•“«*
<10eSn
ZnZL “ “ Cef ‘ - ,‘
g S contt01
Syllabus Topic : STREAMS exchsnZ
Changed ' m
among queues - adjacent "“sages
modules. are
Th
= writef ) or putmsgf ) system cal| is ,
54.6 STREAMS Process for writing the data to device. The write! )
system call is executed to write raw data to the stream,
0. What is STREAMS? Explain. while putmsgf ) permits the user process to state a
message. For any of this system call the stream head
- STREAMS are a mechanism offered by UNIX V
copies the data into a message and sends it to the queue
system. This mechanism allows an application to
assemble pipelines o f driver code dynamically. A for the next module in line.
stream is a full -duplex link between a device driver and This copying of messages carries on till the message is
a user-level process. It consists of a stream head, a copied to the driver end and so the device. In the same
driver end, and zero or more stream modules. Stream
way, the read( ) or getmsg( ) system call is executed by
bead interfaces with user processes. The device is
process to read data from the stream head.
controlled by driver e n d . Zero or more stream modules
exist between stream head and driver end as shown in STREAMS I/O is asynchronous (or nonblocking)
the stream head. The driver end also has a read and
ltat driver end mu5t
write queue. It i» necessary ’
««m module, stream head and driver end. The
*t>onality of S T R E A M S processing is <werc(1 respond to intemipts. for example, one triggered when
a frame is r y to te read from a networic
"“toes. The ioctlf ) system call is used to push
"l“' lul es onto a streams.
Scanned by CamScanner
tom (MU - Sem 4 - IT) 5-60 StojageMan
parallel with CPU and bus operation. Syllabus Topic : File System Implementation
Try to keep balance in performance related to Explain file system structure. (Refer section 5.2.1)
mernoty. CPU, bus and I/O. If one area gets Syllabus Topic : Implementing File System
overloaded then it will cause the area to be idle. Explain the implementation of file system in detail.
(Refer section 5,2.2)
Scanned by CamScanner
cvsjgm (MU - Sem 4
JL)
notes on virtual fj|e sys
&r section 5.2.2(B))
0
io n Stri Star Mana merit
Uc
h<re , 0 p l ' ! !
0v W vi. WrW „
of dir.
, <e: kQeatlo,
* r* * ’»wo., yiical
the diffaren
are ' allocation nph*. W>
(June 2015)
i (Refer section 5.2.5) Example 5,3, 1 2 ( 1 0 M a r k g )
(Dec. 201 5)
Syllabus Topic : RAID Structure
A
(Refer section 5.2.5(A)) Q. Explain various RAID levels.
(Refer section 5. 3. 7(A))
ascribe linked list of disk blocks method.
Syllabus Topic : Tertiary-Storage Structure
(Refer section 5.2.5(B))
Q> Explain various Tertiary-Storage Devices.
r syllabus Topic : Efficiency and Performance
(Refer section 5.3.9(A))
t Explain various techniques to improve efficiency
Syllabus Topic : Swap-Space Management “
and performance of secondary storage.
(Refer section 5,2.6) Q. Explain management of the swap space in detail.
(Refer section 5.3.10)
T
Syllabus Topic : Recovery
Syllabus Topic : I/O systems
1 Explain file system recovery i n detail
Q. Explain different types of I/O devices.
(Refer section 5.2. 7)
(Refer section 5.4.1(A))
r
Whjs Topic : NFS
q. Explain different parameters to distinguish I/O
I Explain operation of network file system in detail. devices. (Peter section 5.4.1(B))
(Peter section 5.2.8(A)) Syllabus Topic: Overview VO Hardware
Scanned by CamScanner
- Sem 4 - rr) 5-62
Q. What is interrupt? Explain the tasks carried out by Syllabus Topic : Kernel I/O Subsystem
Scanned by CamScanner
uted
Systems
Many machines in the same organization can be Users of distributed system feel that, they are working
together through local area network and with a single system.
r
iflformalion can be transferred between machines in a Main characteristics of distributed system
very small amount o f t i m e .
Q. What are its characteristics? Explain.
As a result of these developments, it became easy and
Following are the main characteristics of distributed system,
f Unable to organize c o m p u t i n g system comprising
- A distributed system comprises computers with distinct
large number of m a c h i n e s connected by high speed
architecture and data representation. These
I networks.
dissimilarities and the ways all these machines
;■ Over the period of last thirty years, the price of communicate are hidden from users.
I microprocessors and communications technology _ The manner in which distributed system is organized
constantly reduced in real terms. Because o internally is also hidden from the users of the
I distributed computer systems appeared as a p distributed system.
substitute to uniprocessor a n d centralized sy. r nf users and applications with
r The networks o f computers are present ' sptfe of where and when interactionand identical way. in
occurs
I Internet is composed of many netwo
networks separately a n d in cofnbindt
'° n pertinent _ ■ n ,,ri system should allow rtfor scaling it
A drstn y. It
lll suppo for availabilit
Definition
set of . X *“ “
s application — ------- ---------
computer net work * defm □ together by
r , t . . . ;i re connect
Scanned by CamScanner
erating System (MU ■ Sem 4 - IT) 6-2 sterns
Scanned by CamScanner
multicomputer systems,
hetei
I Tightly coupled systems
Jf JteCP5 a sinfi,e
’ global V je w M hl ~~~ -----
of the
68 SUCh tiEhtl c c 10 r,ie
' fljtf*® * * ou p I e d °pits •X *• "
h
a lled distributed operating S V v,
-o Whkh Wa hmc 10 Other man
*te th ‘ >
™ ®°Ao*”! » c nJnt,in Thc
„ js useful for the manage, qf
°nnect 10 & on J m
rCqUCsl COmpulcr Watchcs
rnulu ‘heruj FTP
i' ' joiuogeneous multicomputer. bos N" Pro C t c of 1O
” °f This d “ n<1
fo]|
Wln aCm
underlying hardware. This hardware ““ d
]s of
& predefined °n res
P° n d s the «:t
q
processes and details reraa i ns Sh
b get' « commands.
ted by ’ Foster fife fT
puter, °m remo|c
computer to local
Z yllabus Topic ; Put: transfer fi]
10ca1 COrn
computer, Puter t0 remote
Network Operating 3
‘ k
Wdir: Uslfik
re
°W computer. current directory on the
621(B) Remote File Transfer After this all access to the file is local. When the user
need is completed, a copy of the file if it has been
- NOS offer a mechanism for remote file transfer from modified is sent back to machine B.
one computer to another. Here, each computer has its Although a small change has been made to a large file,
own local file system. I f a user working on computer A all the data needs to be transferred. This method was
wants to access a file on another computer B, then the used in the Andrew file system. This method of file
file must be copied explicitly from the computer B to transfer is inefficient. In other method of data transfer
computer A . File Transfer Protocol (FTP) is .used for only those portions of the file that are actually needed
such transfer i n internet environment. User invokes the for the immediate task gets transferred.
FTP program as: Jf another part of the file is needed later on, another
transfer will take place. When the user no longer wants
ftp name of computer B
access the file, any part.of it that has been modified
After entering the correct username and passwor , he sent back to machine B. The Sun
should connect to the right subdirectory Xylems Network File System (NFS) protocol
M
L method. The Microsoft SMB protocol
wan
required file. Suppose user ‘ ter B
“ SeS • n top of either TCP/IP or the Microsoft
abc.frt then this file must be copi man d.
3150 a
“ ows fi,e sharing
° wr a
to computer A by executing following co
network.
get abc.txt
Scanned by CamScanner
_ _ Distributed System
L£J Operating System (MU - Sem 4 - IT) 6-4
Scanned by CamScanner
tarn ( M U - Sem 4 - IT)
nd 3
Distributed Systems
faceted
v<k. i" frared ne WOrkS
‘ and
“* Blu., ’
AX,work have comm U m cation speed of “ 1
net l y Conbcc1cd
*orks and i to backbone. Regional
backbone bv r, > ” connected lo routers in
- -
efnetS rou|er
Network ro *re connected to regional
rS
rnodem hank ° Uters a1
Ps are connected to
d jng common. US6d lS S Customere l n thiR
every host ' way,
n nternct
contains several small and large often ° ' has at least one path, and
qoni
_ to every other host.
devlces which
< peripheral « shamble. and
fP 21’ to connect to other networks.
__
n WAN type of network. Q' Explain different topology tor network with its
______ advantages and disadvantages.
■jjs cover a city, country, or the whole world.
* ' met ts collection of thousands of separate networks Machines in distributed system can be connected in
different ways called as topology for that network.
can be considered as one WAN. W A N was
30
i n late I 9 6 0 as a n academic research project to Each topology has its advantages and disadvantages.
Installation cost, communication cost and availability
effc i e n t communication among machines. The
criteria are used to compare different configurations.
objective behind this project was to share
Various topologies are shown i n Figs. 6.4,1, 6.4.2,
are and software i n convenient and economical
6.4.3 and 6.4.4. I n fully connected networks, each node
by a wide community of users. Arpanet is the
is connected to every other node in network. Hence,
number of links increases as square of number of sites.
I waN . machines are physically distributed over a Also installation cost is high. Hence, this topology is
’ ;L geographical area. Therefore communication impractical to consider building the large network.
L jre relatively slower compared to LAN and links A
B )
F „ also not reliable. Internet W A N offer capability for
I communication between different machines whtch are
D
’ computers. Hosts
Hns s are PCs
rc notebooks, handhelds, D
Scanned by CamScanner
Distributed Si
Scanned by CamScanner
department at y ale
Uln
\eisity
address each component h£
, ss i0 system) which takes a
the rcSPOn
C ““ T" *«>le I?"*
name server for the host is . ° , ,hat6 1 -ante.
host-id. Consider Machine J’' ’
X
X t is , issued by process on which
lhe ' Q5w ta t y hj
'’8'Alway S theshorIt .5t lh
Following steps t
lnv
the name athu.it.yale.edu. °lved to ln
'his type of . •
Kernel on host X issue request to nanie 1 8 P>fll f ra
ntJ™' " ' "> “”■>« machine to
edu domain. It ask to name server about ° ff S s
* ®lon. fixed for the duration of one
. -The edu name server’s address U v °
know USed
i fice initial request was issued ‘ °> the f y different sessions to send ’
OmSOurct
jjK? w ------ -----~ "duress Of - U • destination.
tht Shorl like pcriod
Kernel then request to name server v„i , involved in°r **
1 5 trans tr or 85
* it-pcc rtf it x- j j Period h)ng as a remote-login
3
** ' Dynamic routing
dynamic routing, the path used to send a message
conditions change.
routing methods r.““-
zz x. z- - —
used for routing purpose.
used
3. Dynamic routing
Scanned by CamScanner
£EToPgrating System (MU - Sem 4 - IT) 6-8
Distributed S?
slow the communication. File transfer is example of A permanent physical link is established between
reliable connection-oriented service. two processes that want to communicate with each
— Reliable connection -oriented service supports either other.
message sequences or byte streams. Any other process cannot use this established 1
communication session is completed. Hence in cixcujt
- In message sequences message boundaries are
preserved, fn byte streams, the connection is simply a switching, link is allocated to for the duration of
stream of bytes, wilh no message boundaries. communication session.
Scanned by CamScanner
rating System (My .
t sebdP et.
Vision occurs, both the
PUle b
’’ issions. Here both CJ * te _ -
S bjbutad s sterns
ne,w
°iks. Dirf
,“ 1
81 kno
rtponend backoff. «n I
f r
* binary 1“’'’ 5 H** u™
M Sisseton Ethernet f or
- also a maximum number ' mn m cable fen
n ,s
these : simple, . , / ** whether
ronnected to it, a multiple E 'omputers to be
<,n
entire campus- * used l0 wire I
Jl|
it .4 ' « a evice
A bridge is used to connect these
sau,i en,ow
which permits traffic » - mets C?—
,
■
” occurred1
XSr' Ct <>
”
Elhen “ver oh “ ' "channel
“* “wetton
another when the source and destin»« w l0 "’’“mission. PMtcat during
nat, nare
Side. ° m diff NetWork layer : All,k
ne k ,hh
"»o* layer offer, £ *“ " The
f is res
contains ports, to which computer SW
'“ Ch or routing the pack ““ebons P°"siblc
11
another switch can be attached. A Wnder>s °r ™ PS P L~. “"™ on network,
''“versa TlX«
toffeted in switch and sent out on the po rt wh A “
Tranenew 1 ™ ™“ in * “*0™“™.
destination machine stays. As each ____ "“‘“'“•J'r'-i' provides low-level access to the
each machine is It is responsible for tran
connected to separate port ;and collision is eliminated sfer of messages
between clients, includir ’
but requires bigger ltf'all£kc? to connect
switches __ many ing breaking the messages into
mets. sequencing of ’Z
control, and
computers. generating physical addresses
r ession layer-. The session layer is responsible for
Token Passing
establishing the sessions between users. It also
■ Token is a unique message that is circulated in
implements process-to-process communication
network. Any machine want to transmit holds the protocols. It provides services like dialog control,
token. Once transmission completes, it releases token synchronization, token management.
so that other computer can use i t . Token may loss so 6. Presentation layer: This layer deal with syntax and
system should be able to generate new token. semantics of information exchanged between machines.
As machines may have different data representations,
Syllabus Topic : Communication Protocols presentation layer resolve the differences in formats
among the various machines in the network, including
character conversions and half duplex-full duplex
.-Communication Protocols
modes (character echoing).
< Explain different communication protocols. _ _| AuoUcution tayen This layer inUuacb directly with
' It contains different protocols needed by users
compUt
otocol i s o f rules by which e j pyP TTP, Telnet, DNS, and SMTP, This
ttansfcr remolc
coWunicaies with each other. Many pf° tc tals with Gl' ’ ' logm P rotoco,s -
1 t
" *nt such as router-router protocols, and electronic mail.
p,o|
ocols, and others. Protocol stack lay ers
Scanned by CamScanner
Distributed System
JFT Operating System (MU - Sem 4 - FT) .JLL2
dCViCCS &UCh
“ ° n Whicb
- Most of the distributed systems use the Internet as a
met are stored. These files are accessed from these
base. Hence, these system uses two important Internet
devices as per request of client.
protocols: IP (Internet protocol) and TCP
There can be different implementation for DFS. Server
(Transmission Control Protocol), IP (Internet Protocol)
ma y run on dedicated machines. In other
is a datagram protocol. In IP, a sender sends datagram, implementation both client and server may run on Same
of up to 64 KB over the network and no guarantees are machine DFS can be part of DOS or it can be a
given for its delivery. The datagram may be fragmented software layer managing communication between file
into smaller packets and travel independently, possibly system and NOS. DFS should come into view to its
along different routes. At destination host when all client as conventional centralized file system. The
* packets reaches, they are assembled in correct order as servers and storage devices which are on different
per sequence number and delivered to the application. machines in network should be invisible to clients. DFS
- IP protocol has two versions, v4 and v6. Version 4( V4) should fulfill the request of client by arranging the
are currently in use and v6 is up and coming. IP v4 required files or data.
packet starts with a 4O-byte header that contains each - As data transfer is involved in operation of DFS, its
32-bit source and destination address with other fields. performance is measured with amount of time required
These are called IP addresses and routing is carried out to service the client request. Storage space managed by
using these addresses. a DFS includes different and remotely located small
storage spaces.
IP does not offer reliable communication in the
Internet. To offer reliable communication, TCP Syllabus Topic : Naming and Transparency
(Transmission Control Protocol), is present on top of
IP. TCP makes use of IP to offer connection-oriented
6.8 Naming and Transparency
streams. The remote process always listen the incoming
connection on port number. Remote process is - Mapping between logical object and physical object is
specified by IP address of machine and port number. naming. User always knows logical name of the file but
Sender first establishes the connection and sends bytes system has to manipulate the data blocks which is
over that connection which is guaranteed to come out actually stored on disk sectors or tracks. Actually text
the other end undamaged and in the correct order. The name of file gets mapped to numerical identifier which
TCP gives this guarantee by using sequence numbers, in turn again mapped to disk block. Due to such
checksums, and retransmissions of incorrectly received mapping user remains unknown about location of file
on secondary storage.
packets.
In case of DFS, location of file in network remains
Syllabus Topic : Distributed File Systems unknown to the user. This is the new dimension added
to the abstraction with compare to conventional file
6.7 Distributed File Systems (DFS) system. In conventional file system, file remains on
disk of same machine whereas in DFS location of file
Q, Explain working of distributed file system (DFS). can be in disk of any machine in the network. File
— In distributed system, files are available on several replication is supported i n DFS so that several replica
computers. Computers in distributed system can share of file exist. By given file name then set of locations of
these physically dispersed files by using distributed file the file is returned by mapping.
system. Service offers particular function to client and
it is a software entity running on some machines. 6.8.1 Naming Structures
Server runs service software on single machine. Client
process invokes the service through some set of defined Name mapping should support location transparency
File system offers file services to clients. ITie set of 1. Location transparency : Physical storage location of
primitive file operations are create a file, delete a file, file cannot be known by using file name.
read from a file, and write to a file. Client interface is
formed with set of these operations. File server controls
Scanned by CamScanner
System (MU - Se
______ _
[J Ctun independence , AhhZr** ».,
Chan8eS lherc
r ’ « »»
1 16
Sk"' ” ' (k. Distrihirtmj Systems
n* clHie nt DFS system ,
d v l 1 PprDKh
S a ic ' ' Lld' L is in network file system
. ‘ ’ PPir Su
n,grj 8 "'•Wortcin. ’ " " yaterns.
" ted by these systems. Henri '
“ion is
QNC+ a
noil ot “PPorted by many UNIX
on O f
sterns. xr po,K
__ " 1 — i networking
‘ tion independence is suptxjrted ltu
Ulen files o cok tor
“ s to
local a-" ra “ hamsm to attach remote
►’ « l o » ---------
caJ data
™n (a ,„,,crs
----------" ers that
tha[ ar P
Can
be
intrud Uc eddircctOT
now j V u ? s
Which
autOrn
°unt feature is
appeare to u
n
" , speeifv borage location. If on . ' Cached
parency is supported, the fi le kx , on a ’ m °unts arc done on demand,
mou
names. nt points and Restructure
1
“f of physical disk blocks although J **1 to
gn the h thind apDrn
hidden from users. * block,
in a
location transparency, users can sharp name stru
are covered
r)1 Saturn s , cture. This file-system
n)s
the
simply by naming the fil e s in t m0le c entional file lsom
<>rphic to the structure of a
ner j t B® *e files are local. I n this "X "’ tTUkes
« diffi cu i7t tem PraCt
‘Cally * some special files
storage space is cumbersome. ’ Sdarin g 8 l<Jbal name structure ** om
<teh lhe
8 of single
approaches 1,1051
ge
WoLh ? ’ complex is the
' end data objects as well. Hence, i t i s u “°" by WS slructure is
practicall
Really most diffici)lt (o complex
As and
, t aivows
' balancing the disk utilization across the system ,
remote ditectQry
naming hierarchy is separated fr O m lhe “
comes more unstructured, Due to non availability of
' of storage devices hierarchy and front the inter t some directories on different computers also
computer structure. Once separation between file name
become unavailable,
and storage space completes, client can now access file
6
remote server also. 8.3 Implementation Techniques
Scanned by CamScanner
Distributed System
LEJ Operating System (MU - Sem 4 - IT) 6-12
— Structured names arc commonly used for low-level - If granularity of caching is large size chunks then hit
identifiers. These names are bit strings with two parts. ratio increases. But, if miss occurs then more data is
The first part is component unit to which the file needed to retrieve from server which increases network
belongs. The second part indicates a file within the traffic. It in turn will increase the possibility Qf
unit. Implementation with more than two parts is also consistency problems as well. The network transfer unit
possible. This explained technique is used in Andrew and the RPC protocol service unit should be taken into
File System (AFS). account wile selecting unit of caching. For large caches
large block sizes are beneficial.
Syllabus Topic : Remote File Access
6.9.2 Cache Location
6.9 Remote File Access Cache location can either be main memory or disk If
cache is kept in main memory then modifications done
Suppose, client forward the request to server to access
on cached data will lost due crash. If caches are kept in
remote file. Naming scheme locates the server and
disk then they are reliable. No need to fetch the data
actual data transfer between client and server is
during recovery as data resides on disk. Following are
achieved through remote-service mechanism. In this
mechanism, request for accesses is forwarded to server, the advantages of main memory caches.
which then performs accesses and returns (he result to o II permits for diskless workstations
user or client. This is similar to disk accesses in o Data access takes less time from main memory
conventional file system. . compared to access from disk.
- Caching can be used to improve performance of o Performance speed up is achieved with larger and
remote-service mechanism. In conventional file system, inexpensive memory which technology demands
caching is used to reduce disk I/O. The main goal today.
behind caching in remote-service mechanism is to
o To speedup I/O server caches are kept in main
reduce network traffic and disk I/O. Following are
memory. If both server caches and user caches are
basic caching schemes in DFS.
kept in main memory then single caching
6.9.1 Basic Caching Scheme mechanism can be used for both.
Many remote-access implementations take the hybrid
- If data needed for operation is not cached by client then
approach considering both, caching and remote service.
it send request to server for the same. Now, client
In NFS, for example, the implementation is based on
performs the accesses on cached data which is sent by
remote service but is improved with client- and server
server. Ail the future repeated accesses to this recently
side memory caching for performance.
cached data can be carried out locally. This will reduce
additional network traffic. 6.9.3 Cache-Update Policy
Least Recently Used (LRU) algorithm can be used for
- System's performance and reliability depends on the
replacing the cached data. Master copy of file is
policy used to write back updated data to the master
available on server and its part is scattered on many
copy of file which is available on server. Following
client machines. If copy of the file at client side
modifies then its master copy at server should be policies are used.
Scanned by CamScanner
System ( M U . Setti
retems [ S P iS d e l a
> - writin. th
master copy on server. M "«
ien hit
iata is
advan,a
twork I L 8 c <>f this J dooe
on n. ten
m le
operation becomes active “ <*
Is
policy is
6
| ysed in Andrew File System (AFS), -9 5 A Comp
Ing and Remote
L Consistency Service
I Client machine always use cached data for accesses dlflefenCe betwe8n rem
racing? ote service and
fcjj is consistent with master copy at server. If client
Sr. No. Caching
amines that its cached copy i s o u t of date, then it should Remote Service
I. It allows to serve Remote access is
it the up-to-date copy of data. Following two
remote accesses handled across the
oacbes are used.
locally so that they network, so slower
Two approaches of can be faster as compared to caching.
consistency local accesses
Scanned by CamScanner
Distributed Systems
Operating System (MU - Sem 4 -JT).
<r Stateless File Service
Sr. No u Caching [ Remote Service
In remote service, in this case server does not keep any information in
4. I Caching is better ir
there is always main memory about opened files. Here, each request
J case of infrequen
I writes but if writes communication identifies the file. There is no need to open arid close
I are frequent then between client and the file with operations open( ) and closef ).
I mechanism used to server to have a - Each file operation in this case is not a part of session
overcome master copy
but it is on its own separately. Closing the file at last is
J consistency consistent with
also a remote operation, NFS is example of stateless
I problem incur large client’s cached copy.
file service approach.
I overhead in terms
I of performance. Stateful service gives more performance. As
' network traffic, connection identifier is used to access information
and server load. maintained in main memory, disk accesses are reduced.
If machines are Moreover, as server knows that file is open for
I 5, | Caching is better
option for diskless and with sequential access, then read ahead next block improves
machines with disk small main memory the performance. In stateful case, if server crashes then
or large main then remote service recovery of volatile state information is complex. A
memory. should be carried out. dialog with client is used by recovery protocol. Server
6. In case of caching, The remote service also needs to know about crash of client to free the
■ . the lower- level concept is just an memory space allocated to it. All the operation
nter-machinc extension of the local underway during crash should be aborted.
nterface is file-system interface In case of stateless service, the effect of server crash
I t lifferent from the across the network.
and recovery is invisible. Client keeps retransmitting
I u ppcr-Icvcl user
the requests if server crash and no response from it.
if i terface.
I
Syllabus Topic : File Replication
Syllabus Topic : Stateful Versus Stateless Service
6 J 1 File Replication
6JO Stateful Versus Stateless Service
Replicating the file on many machines improves
Client access the remote files from server. If server
availability. If nearest replica is used then service time
keeps track about each file being accessed by each
also reduces. The replica of the same file should be
client then the service is called stateful. If server is
kept on failure independent machines so that
simply provides requested blocks of data to client and
availability of one replica is not affected by availability
does not keep track about how client makes use of them
then service is called stateless. of remaining other replica. Replication of files should
be hidden from users.
Stateful File Service
It is the responsibility of naming scheme to a replicated
First client must cany out open( ) operation on file
file name to a particular replica. Higher levels should
prior to accessing it. Server the access information
remain invisible from existence of replicas.
about file from disk and store in main memory.
At lower-level different lower-level names are used for
Server then gives unique connection identifier to client
different replicas. Replication control such as
and opens the file for client. This identifier is used by
determination of the degree of replication and
client to access the file throughout the session.
placement of replicas should be provided to higher
On closing of the file. or by garbage collection
levels. As one replica updates then from user’s point of
mechanism, the server should free the main memory
view, the changes should be reflected in other copies as
space used by client when it is no longer active. The
well.
mformatton maintained by server regarding client is
e d m fault toterance, AFS uses stateful approach
Scanned by CamScanner
?d Systems
(n _ (J Distributed Systems
me5 ltldudin
i ituition in *ge 8 itself, in this request
centralized synchronization nie . ' *hich request SLarT1p
’Seating the time at
ch request
nie SCnt
I Lj to distributed environment also C
be ssaget ot | ler ‘ receiving this request
arid close
I 4 imtnc
diate|vn ;/ r<1CeSS may 5410(1
reply message
r
Mutu a l Exclusion If ydefCTit
of session P ess w
s at last is f gxpiafnddferent algorithms for mijh Pr °ce$s i s alre d uest
message from other
cr l c a l
I distributed system. Queued. When . ‘ section, then request is
* stateless
reply lo reou ‘ ° Or, ' eS ° u l critical section, it sends
. U T rcnt algorithm, Io achlew J reply from a|R nfi process
‘ If
requesting process gets
ice. As pr cesses lt can enter in
' n in distnbuted environment. There are s u mUtual critical section " ' °
>o
urination i n system
‘' h e r of nnntbered f roni , “ PP0Se "
reduced, 0 n u immOlia,dy
has its own processor ‘ ’d “'Pends ' on following factors. » it deferred
’pen for
1 [f
mproves process receiving request message is in critical
hes then •on then it defers the reply to requesting
iplex. A process.
„ Server
free the to enter in critical section then it immediately
aeration , lD this algorithm, one of the proceS5 sends reply to requesting process.
coordinator. Each process want to enter in critical
I f process receiving request message also want
section sends request message to coordinator. If process
r crash enter in critical section then, it compare its time
then receives reply message from coordinator then stamp with time stamp of requesting process. If its
nutting
proceed to enter in critical section. Once process finish time stamp is greater than lime stamp of incoming
it.
request then it immediately sends request
coordinator and continue its execution. message. Otherwise the reply is postponed.
After receiving the request, first coordinator checks In this algorithm, mutual exclusion and no deadlock is
whether critical Section i s empty or not. If empty then guaranteed. There is no starvation as time stamp is used
coordinator sends reply message to requesting process to ensure FCFS strategy to serve. Exact 2(n-l) number
proves of messages arc required to exchange to enter in critical
and process enters in critical section. If other process is
j time section which is less compared to if processes act
already in critical section then request of requesting
Id be independently and concurrently.
process is queued.
that Following are the limitations of this algorithm.
biiity - When coordinator receive release message from
1. Processes should know names of all other
KJuld process exiling from critical section, one of the
processes in group. There is problem when new
processes from q ue u e is chosen to enter in critical
process joins the group. In this case, processes
:ated section based o n some scheduling algorithm. If FIFO
must receive names of all other processes in
ould strategy is used then no starvation can occur. Three group. Suppose, request and reply messages are in
messages request, reply and release are used in transit and new process joins the group, then
algorithm. problem definitely will arise.
I for
as , If anyone process fails, then requesting process
•■12.1(B) Fully Distributed Approach
and ■ wi jl not receive reply message from it. The
her 1 monitoring of all processes slate is required and
Explain distributed algorithm for mutual exclusion notification regarding fail process need to be sent
tof in distributed system. ------------------------------------------1
, ,11 other processes in group. Thts is required so
> as J - y o l v e d in decision
esS sh0UW Send thC req
fa this algorithm
*
a l l processes arc mv
x* tn efliC*
critical thaX P “ eSt l
°
to
allow the requesting process cr itical failed process. ‘ __________
cn
xwion. Process Pi which want to olher
Scanned by CamScanner
6-16 Distributed System
Operating System (MU ■ Sern 4 TQ
3. h is necessary to pause (he processes frequently control is the responsibility of transaction manager. i t
that have not taken entry in their critical section. also maintains log for future recovery purpose.
This is required to guarantee other processes that
6.13.1 Locking Protocols
they want to enter the critical section.
And hence, this algorithm is better suited to small and - Two-phase locking protocol also works for distributed
stable sets of cooperating processes. environment. In this case implementation of loc
manager differ compare to single system environment
6.12.1(C) Token-Passing Approach
6.13.1(A) Non replicated Scheme
In this algorithm, a token which is a special type of
message circulated in the system. Process acquiring - This scheme is used when data is not repliCat£d
token can enter in the critical section which ensures a system. In this scheme, there is a local lock manager Un
single process in critical section at a time. In this each site to manage the lock and unlock requests for
algorithm, processes in the system are assumed as those data items stored in that site. In order to lock the
logically organized in a ring structure. This logical data item X on site Si, process simply send message to
arrangement can be based on some parameter, for lock manager on that site.
example, integer value of IP address of the machine on If X is locked in incompatible mode then the request is
which process is running. delayed until that request can be granted. Once it has
Token circulates around the ring and process which been decided that the lock request can be approved, the
want to enter in critical section holds the token and lock manager sends a message back to the initiator
enter in critical section. After the process exits its showing that the lock request has been granted.
critical section, the token is circulated again in ring. In The implementation of this scheme is easy. It needs
this scheme, process exiting from critical section passes
only two message transfers for handling lock requests
the token to its neighbour. In this algorithm,
and one message transfer for handling unlock requests
unidirectional link guarantees the freedom from B u t , deadlock handling is more complex.
starvation.
One message per entry is required to enter in critical if 6.13.1(B) Single-Coordinator Approach
all the processes want to enter in critical section, if no
This scheme is used when data is replicated. In this
one want io enter in critical section then infinite
scheme, single lock manager resides on particular
number of messages may require. Limitations of this
selected site Si. For locking and unlocking the data
algorithm are:
item, all request are sent to this site. Any transaction
1. Token may lost. In this case election needs to be want io lock ihe data item, sends lock request to Si and
called to generate new token. lock manager decides whether to grant lock without
2, Failure of any process requires establishing a new delay or not.
ring.
It immediately lock request is granted, then lock
manager instantly sends message to the site from where
Syllabus Topic : Concurrency Control
request was sent.
6.13 Concurrency Control If request not granted, then it is delayed till it is granted
and again message is sent to the requesting site.
This section explains concurrency control schemes for The transaction can read the data item from any one of
distributed environment. The management of the the sites at which a replica of the data item resides.
transactions or subtrabsactions accessing database on
In case of write operation, all the sites having replica
the local site is earned out by transaction manager of
should take part in the writing.
distributed database system.
Advantages
- Transaction can be local or it can be part of the
transaction running at other sites. The concurrency Implementation is simple as only two messages are
required to handle lock request and one message to
Scanned by CamScanner
System (MU
ck on s t n 8 Je system
request are f rom same’s ” -a 1Qck
pfM****" Shi
Distributed Svstems
mana
. . sing* '<“* ger reside On „ T
si , site Si may be «, ° the I
1 d X
sing o f a* *e request, then . "““ck due ? " onsite hT "‘ 'X' x" ' ’' an5Mion s
'Wiy
done r f ,s E P,iCa f
> » * ° must stOp ‘ * ’«u.lv. X ‘" ° x.~
solution to avoid bottle n e c k hen □ t
z j; rta tor approach. Lock ° mnk...
to
x. u
lngare lock
° Plica O f X " ager at each site
If
* e *que st b eRntCd lhen
lock priest is delayed tv response to that
n S SC e m e
° read operation ■ ’m POses less overhead
3 1(C) M a J°rity Protocol vantage E ive _ mpared lo
majority protocol. This
reSU
majority p jn compared t ’ tS When morc
arc reads
Writts extra
■s incurred a ‘ overhead on write
I %is approach is modification of nonrcnli handling
ln com i S . many Sltes involved, deadlock
da,a
EcomplexiUes exists.
' srheoie. In “heme lock manager i s pra , c ?. 3/1
(E) Primary Copy
| iiIe . The locks for all data or repIica o f d ata ™ sX
In this aDDroach
inning on that
| site- tv - zv wmcn ls kept on exactly on one site
1
. For this
m X, this is called as primary site of X. When
I if data item is replicated on n number of sitcs
saction needs to lock data item X, it should request
transaction want to lock this data item. Then it js
st primary site of X, If the request is not granted
necessary to send the lock request to more than one-
half of the n sites. Lock manager decides whether to The concurrency control for replicated and
grant the lock or should response be delayed. The nonreplicated data is handled in the same way.
transaction does not operate on replicated data item Implementation is straightforward. If primary site of -
- Avoids the drawback o f central control approach. A unique timestamp is given to each transaction based
r
Disadvantages on which serialization order is decided.
613.1(D) Biased Protocol In the distributed method, every site generates a local
timestamp which is unique. For this, either a logical
a ori
Tfe working of biased protocol is close to the J counter or the local, clock is used. The global unique
Protocol. In biased protocol, requests for S timestamp >s 8 enerated by concatenat,on of ,he
Scanned by CamScanner
Distributed Systems
wUon ls
impleme« from thc selected process
faster rar eomparelI o limeslwn ps me5S
The number |afge , Hence, it may become
ste . s nmestw" , „ s« 5hould be
as banker may banker’s algorithm does not
bottleneck M ‘ & distribdted systenv
X
there to guarantee hat umestarups will be generated >»
mat,
fair manner across the system. aDuear to be of praccre .
Padlock-prevention scheme that considers a
A
« — " Xng approach with resource preemption
‘"’’“‘X any deblock situation that may happen in a
can
generation o f timestamps. h red system Consider only a ease of a single
Xce of each resource type. A unique priority
‘ is aiven to each process in order <0 control the
Scanned by CamScanner
terr (MU - S e m 4 - m
dn<J ®
S-19
Detection
Distributed System
graphs.
If this global wait-for graph contains cycle then system This happens due to delay incurred in reaching the
isin deadlocked state, messages from different local sites to coordmator.
P3 for deadlock
(P5
1
de 0O ±
043 : Global wa ,t-for graph after union of ------; TT Tthe sires are involved in deadlock
for graphs at site Si and Si ,h,S
“P Each sitt builds a wait-for graph indicating a
de,eCtl
i-for graphs can be organized m g ° n ; h ; total graph, tending on the dynamic
C
f the system. The thought is that, if a
baviof ot u _____________
Scanned by CamScanner
Distributed Systems
6-20
Tcommumcation Structure .
deadlock exists, a cycle will appear in at least one of naminq? How names are resolved?
Q. What is naming ,
' the partial graphs.
In «, approach, each she — "
graph. In each local wait-for graph, we „ O. Explain different routing strategies.
P Edge Pi to P„ in graph indicates Pi J* wai i g (Refer section 6.5.2)
Q. Define distributed system. (Refer section 6. 1) <r Syllabus Topic : Distributed Synchronization
Q. What are its characteristics? Explain. Q. Explain centralized algorithm for mutual exclusion in
(Refer section 6. 1.1) distributed system. (Refer section 6.12.1(A))
Q. What are objectives behind building the distributed Q. Explain distributed algorithm for mutual exclusion in
system? (Refer section 6. 1.2) distributed system. (Refer section 6.12.1(B))
Q. What are the reasons behind process migration? Syllabus Topic : Deadlock Handling
(Refer section 6.2.2(C))
Q. Explain deadlock prevention and avoidance in
Syllabus Topic : Network Structure distributed system. (Refer section 6.14.1)
* f
Syllabus Topic : Network Topology Q. Explain distributed algorithm for deadlock detection
Explain different topology for network with its in distributed system. (Refer section 6.14.2(C))
Scanned by CamScanner