0% found this document useful (0 votes)
30 views63 pages

Module 5 - Storage Management

The document discusses file and disk management, focusing on magnetic disks' structure, performance parameters, and disk scheduling algorithms. It explains various disk scheduling techniques such as FCFS, SSTF, SCAN, C-SCAN, and LOOK, highlighting their advantages and disadvantages. The document emphasizes the importance of optimizing seek time and access time for efficient disk operations.

Uploaded by

dev339255
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views63 pages

Module 5 - Storage Management

The document discusses file and disk management, focusing on magnetic disks' structure, performance parameters, and disk scheduling algorithms. It explains various disk scheduling techniques such as FCFS, SSTF, SCAN, C-SCAN, and LOOK, highlighting their advantages and disadvantages. The document emphasizes the importance of optimizing seek time and access time for efficient disk operations.

Uploaded by

dev339255
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

FILE AND DISK MANAGEMENT

MODULE 5
STORAGE MANAGEMENT

MODULE 5
CO6 : Explain the security aspects and algorithms
for file and storage management in Operating
Systems. (Cognitive knowledge: Understand)

NVV’s 3
Overview of Mass-Storage Structure
• Magnetic Disks
• Magnetic disks provide the bulk of secondary storage for modern computer
systems.

NVV’s 4
Magnetic Disks
• The entire disk is divided into platters.

• Each platter consists of concentric circles called as tracks.

• All the tracks of a disk have the same storage capacity.

• These tracks are further divided into sectors which are the smallest
divisions in the disk.

• A cylinder is formed by combining the tracks at a given radius of a disk


pack.

NVV’s 5
Magnetic Disks

NVV’s 6
Magnetic Disks

• There exists a mechanical arm called as Read / Write head.


• It is used to read from and write to the disk.
• Head has to reach at a particular track and then wait for the rotation of
the platter.
• The rotation causes the required sector of the track to come under the
head.
• Each platter has 2 surfaces - top and bottom.
• Both the surfaces are used to store the data.
• Each surface has its own read / write head.

NVV’s 7
Magnetic Disks

NVV’s 8
Magnetic Disks
• Disk Performance Parameters:
• The time taken by the disk to complete an I/O request is called as disk
service time or disk access time.
• Components that contribute to the service time are:
1. Seek time
2. Rotational latency
3. Data transfer rate
4. Controller overhead
5. Queuing delay

NVV’s 9
Magnetic Disks

• Seek time
• The time taken by the read / write head to reach the desired track is called
as seek time.
• It is the component which contributes the largest percentage of the disk
service time.
• The lower the seek time, the faster the I/O operation.
• Seek time specifications include:
1) Full stroke
2) Average
3) Track to Track

NVV’s 10
Magnetic Disks
• Full stroke
• It is the time taken by the read / write head to move across the entire
width of the disk from the innermost track to the outermost track

• Average
• It is the average time taken by the read / write head to move from one
random track to another.
• Average seek time = 1 / 3 x Full stroke

• Track to Track
• It is the time taken by the read-write head to move between the
adjacent tracks.

NVV’s 11
Magnetic Disks
• Rotational Latency
• The time taken by the desired sector to come under the read / write head is called
as rotational latency.
• It depends on the rotation speed of the spindle.
• Average rotational latency = 1 / 2 x Time taken for full rotation

• Controller Overhead
• The overhead imposed by the disk controller is called as controller overhead.
• Disk controller is a device that manages the disk.
• Queuing Delay
• The time spent waiting for the disk to become free is called as queuing delay.

NVV’s 12
Magnetic Disks

• Data Transfer Rate


• The amount of data that passes under the read / write head in a given
amount of time is called as data transfer rate.
• The time taken to transfer the data is called as transfer time.
• It depends on the following factors:
1. Number of bytes to be transferred
2. Rotation speed of the disk
3. Density of the track
4. Speed of the electronics that connects the disk to the computer

NVV’s 13
Magnetic Disks

Disk access time


= Seek time + Rotational delay + Transfer time + Controller
overhead + Queuing delay

Average disk access time


= Average seek time + Average rotational delay + Transfer time +
Controller overhead + Queuing delay

NVV’s 14
Disk Scheduling

• Disk scheduling is a technique used by the operating system to schedule


multiple requests for accessing the disk.

• The algorithms used for disk scheduling are called as disk scheduling
algorithms.

• The purpose of disk scheduling algorithms is to reduce the total seek


time.

NVV’s 15
Disk Scheduling Algorithms

NVV’s 16
FCFS Scheduling
• In First Come First Serve (FCFS) , the requests are served in the order
they come.
• This is the simplest algorithm
• Advantages
• It is simple, easy to understand and implement.
• It does not cause starvation to any request.
• Disadvantages
• It results in increased total seek time.
• It is inefficient.

NVV’s 17
FCFS Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The FCFS scheduling algorithm
is used. The head is initially at cylinder number 53. The cylinders are
numbered from 0 to 199. Find the total seek time while servicing these
requests.

NVV’s 18
FCFS Scheduling
• Solution :

Total seek time


= (98 – 53) + (183 – 98) + (183 – 41) + (122 – 41) + (122 – 14) + (124 – 14) + (124 – 65) + (67 – 65)
= 45 + 85 + 142 + 81 + 108 + 110 + 59 + 2
=632

NVV’s 19
FCFS Scheduling
• Example2 : Suppose the order of request is- (82,170,43,140,24,16,190) and
current position of Read/Write head is : 50 . Assume the disk has 200
cylinders ranging from 0 to 199. Find the total seek time while servicing
these requests.

Total seek time:


=(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16)
=642

NVV’s 20
SSTF Scheduling

• Shortest -seek-time-first (SSTF) algorithm

• The SSTF algorithm selects the request with the least seek time
from the current head position.

• SSTF chooses the pending request closest to the current head


position

NVV’s 21
SSTF Scheduling

• Advantages
• It reduces the total seek time as compared to FCFS.
• It provides increased throughput.
• It provides less average response time and waiting time.

• Disadvantages
• There is an overhead of finding out the closest request.
• The requests which are far from the head might starve for the CPU.
• Switching the direction of head frequently slows down the algorithm.

NVV’s 22
SSTF Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The SSTF scheduling algorithm
is used. The head is initially at cylinder number 53. The cylinders are
numbered from 0 to 199. Find the total seek time while servicing these
requests.

NVV’s 23
SSTF Scheduling
• Solution :

Total Seek time =


= (65 – 53) + (67 – 65) + (67 – 41) + (41 – 14) + (98 – 14) + (122 – 98) + (124 – 122) + (183 – 124)
= 12 + 2 + 26 + 27 + 84 + 24 + 2 + 59
= 236

NVV’s 24
SSTF Scheduling
• Example2 : Suppose the order of request is- (82,170,43,140,24,16,190) and
current position of Read/Write head is : 50 . Assume the disk has 200
cylinders ranging from 0 to 199. Find the total seek time while servicing
these requests.

Total seek time:


=(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170)
=208

NVV’s 25
SSTF Scheduling

• Consider a disk system with 100 cylinders. The requests to access the
cylinders occur in following sequence-
4, 34, 10, 7, 19, 73, 2, 15, 6, 20
• Assuming that the head is currently at cylinder 50, what is the time taken
to satisfy all requests if it takes 1 ms to move from one cylinder to adjacent
one and shortest seek time first policy is used?

NVV’s 26
SSTF Scheduling

Total head movements incurred while servicing these requests


= (50 – 34) + (34 – 20) + (20 – 19) + (19 – 15) + (15 – 10) + (10 – 7) + (7 – 6) + (6
– 4) + (4 – 2) + (73 – 2)
= 16 + 14 + 1 + 4 + 5 + 3 + 1 + 2 + 2 + 71
= 119

Time taken for one head movement = 1 msec. So,


Time taken for 119 head movements
= 119 x 1 msec
= 119 msec
NVV’s 27
SCAN Scheduling

• This algorithm of scans all the cylinders the disk back and forth.
• Head starts from one end of the disk and move towards the other end
servicing all the requests in between.
• After reaching the other end, head reverses its direction and move
towards the starting end servicing all the requests in between.
• The same process repeats.
• SCAN Algorithm is also called as Elevator Algorithm.
• This is because its working resembles the working of an elevator.

NVV’s 28
SCAN Scheduling
• Advantages
• It is simple, easy to understand and implement.
• It does not lead to starvation.
• It provides low variance in response time and waiting time.

• Disadvantages
• It causes long waiting time for the cylinders just visited by the head.
• It causes the head to move till the end of the disk even if there are
no requests to be serviced.

NVV’s 29
SCAN Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The SCAN scheduling algorithm
is used. The head is initially at cylinder number 53. The cylinders are
numbered from 0 to 199. Find the total seeks while servicing these
requests.

NVV’s 30
SCAN Scheduling
• Solution :

Total Seek time =


= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 41) + (41 – 14)
=12 + 2 + 31 + 24 + 2 + 59 + 16 + 158 + 27
= 331

= (199 – 53) + (199 – 14)


OR = 146 + 185
NVV’s 31
SCAN Scheduling
• Example2 : Suppose the order of request is- (82,170,43,140,24,16,190) and
current position of Read/Write head is : 50 . Assume the disk has 200
cylinders ranging from 0 to 199. Find the total seek time while servicing
these requests.

Total seek time:


=(199-50)+(199-16)
=332

NVV’s 32
C-SCAN Scheduling

• Circular-SCAN Algorithm is an improved version of the SCAN


Algorithm.
• Head starts from one end of the disk and move towards the other end
servicing all the requests in between.
• After reaching the other end, head reverses its direction.
• It then returns to the starting end without servicing any request in
between.
• The same process repeats.

NVV’s 33
C-SCAN Scheduling
• Advantages
• The waiting time for the cylinders just visited by the head is reduced as compared
to the SCAN Algorithm.
• It provides uniform waiting time.
• It provides better response time.

• Disadvantages
• It causes more seek movements as compared to SCAN Algorithm.
• It causes the head to move till the end of the disk even if there are no requests to
be serviced.

NVV’s 34
C-SCAN Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The C-SCAN scheduling
algorithm is used. The head is initially at cylinder number 53. The cylinders
are numbered from 0 to 199. Find the total seeks while servicing these
requests.

NVV’s 35
C-SCAN Scheduling
• Solution :

Total Seek time =


= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) + (199 – 0) +
(14 – 0) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 27
= 386

= (199 – 53) + (199 – 0) + (41 – 0)


OR
= 146 + 199 + 41 =386 36
NVV’s
C-SCAN Scheduling
• Example2 : Suppose the order of request is- (82,170,43,140,24,16,190) and
current position of Read/Write head is : 50 . Assume the disk has 200
cylinders ranging from 0 to 199. Find the total seek time while servicing
these requests.

Total seek time:


=(199-50)+(199-0)+(43-0)
=391

NVV’s 37
LOOK Scheduling
• LOOK Algorithm is an improved version of the SCAN Algorithm.

• Head starts from the first request at one end of the disk and moves
towards the last request at the other end servicing all the requests in
between.

• After reaching the last request at the other end, head reverses its
direction.

• It then returns to the first request at the starting end servicing all the
requests in between.
• The same process repeats.
NVV’s 38
LOOK Scheduling

• The main difference between SCAN Algorithm and LOOK Algorithm is:

• SCAN Algorithm scans all the cylinders of the disk starting from one end to the
other end even if there are no requests at the ends.

• LOOK Algorithm scans all the cylinders of the disk starting from the first request at
one end to the last request at the other end.

NVV’s 39
LOOK Scheduling

• Advantages
• It does not cause the head to move till the ends of the disk when there are no
requests to be serviced.
• It provides better performance as compared to SCAN Algorithm.
• It does not lead to starvation.
• It provides low variance in response time and waiting time.

• Disadvantages
• There is an overhead of finding the end requests.
• It causes long waiting time for the cylinders just visited by the head.

NVV’s 40
LOOK Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The LOOK scheduling algorithm
is used. The head is initially at cylinder number 53. The cylinders are
numbered from 0 to 199. Find the total seeks while servicing these
requests.

NVV’s 41
LOOK Scheduling
• Solution :

Total Seek time


= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 41) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 142 + 27
= 299

= (183 – 53) + (183 – 14)


= 130 + 169
OR
= 299 42
NVV’s
C-LOOK Scheduling
• Circular-LOOK Algorithm is an improved version of the LOOK
Algorithm.
• Head starts from the first request at one end of the disk and moves
towards the last request at the other end servicing all the requests in
between.
• After reaching the last request at the other end, head reverses its
direction.
• It then returns to the first request at the starting end without servicing
any request in between.
• The same process repeats.

NVV’s 43
C-LOOK Scheduling
• Advantages
• It does not cause the head to move till the ends of the disk when
there are no requests to be serviced.
• It reduces the waiting time for the cylinders just visited by the head.
• It provides better performance as compared to LOOK Algorithm.
• It does not lead to starvation.
• It provides low variance in response time and waiting time.
• Disadvantages
• There is an overhead of finding the end requests.

NVV’s 44
C-LOOK Scheduling

• Example 1: Consider a disk queue with requests for I/O to blocks on


cylinders 98, 183, 41, 122, 14, 124, 65, 67. The C- LOOK scheduling
algorithm is used. The head is initially at cylinder number 53. The cylinders
are numbered from 0 to 199. Find the total seeks while servicing these
requests.

NVV’s 45
C-LOOK Scheduling
• Solution :

Total Seek time


=(65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 14) + (41 – 14)
=12 + 2 + 31 + 24 + 2 + 59 + 169 + 27
= 326

= (183 – 53) + (183 – 14) + (41 – 14)


= 130 + 169 + 27
OR = 326
NVV’s 46
Disk Formatting
• Disk formatting is the configuring process of a data storage media such
as a hard disk drive, floppy disk or flash drive for initial usage.

• Disk formatting is usually required when new operating system is going


to be used by the user.

• It is also done when there is space issue and we require additional space
for the storage of more data in the drives.

• When we format the disk then the existing files within the disk is also
erased.

NVV’s 47
Disk Formatting

NVV’s 48
Disk Formatting

• Low-level formatting
• A new magnetic disk is mainly a blank slate.
• It is platters of the magnetic recording material.
• Before a disk may hold data, it must be partitioned into sectors that
may be read and written by the disk controller.
• It is known as physical formatting and low-level formatting.

NVV’s 49
Disk Formatting
• Low-level formatting
• Low-level formatting creates a unique data structure for every sector on
the drive.
• A data structure for a sector is made up of a header, a data region, and a
trailer.
• The disk controller uses the header and trailer to store information like an
error-correcting code (ECC) and a sector number.
• When the controller writes a sector of data during normal I/O, the ECC is
updated with a value calculated from all the bytes in the data area.
• When the sector is read, the ECC is recalculated and compared with the
stored value.
• If the stored and calculated numbers are different, this mismatch indicates
that the data area of the sector has become corrupted and that the disk
NVV’s
sector may be bad. 50
Disk Formatting
• Low-level formatting
• Most hard disks are low-level-formatted at the factory as a part of the
manufacturing process.
• This formatting enables the manufacturer to test the disk and to initialize the
mapping from logical block numbers to defect-free sectors on the disk.
• During low-level formatting, the manufacturer sets up the disk's physical parameters,
such as the number of tracks and sectors per track, using specialized equipment and
firmware.
• It is usually possible to choose sector size among a few sizes, such as 256, 512, and
1,024 bytes.
• Formatting a disk with a larger sector size means that fewer sectors can fit on each
track; but it also means that fewer headers and trailers are written on each track
and more space is available for user data.
• Some operating systems can handle only a sector size of 512 bytes

NVV’s 51
Disk Formatting

• Partitioning
• Before it can use a disk to hold files, the operating system still needs
to record its own data structures on the disk.
• It does so in two steps.
• Partitioning
• Logical Formatting

NVV’s 52
Disk Formatting

• Partitioning
• Partitioning the disk into one or more groups of cylinders.
• The operating system can treat each partition as though it were a
separate disk.
• One partition can hold a copy of the operating system’s executable
code, while another holds user files.

NVV’s 53
Disk Formatting

NVV’s 54
Disk Formatting
• Logical Formatting (High Level Formatting)
• It is the creation of a file system.
• In this step, the operating system stores the initial file-system data
structures onto the disk.
• The file system determines how data is organized, stored, and
accessed on the disk.
• Common file systems include FAT (File Allocation Table), NTFS
(New Technology File System), and ext4 (used in Linux).
• The high-level formatting process also involves creating a boot
sector or master boot record (MBR) to enable the system to start
from the disk.

NVV’s 55
Disk Formatting

• Logical Formatting (High Level Formatting)


• High-level formatting involves initializing the disk's file
system structures, creating directories, and setting up the
metadata required for storing and retrieving files.

• This process prepares the disk for storing data in a


structured and organized manner.

NVV’s 56
Disk Formatting
• Logical Formatting (High Level Formatting)

NVV’s 57
Tutorial – Disk Scheduling
Q1. Consider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200
cylinders (numbered as 0, 1, … , 199), and 256 sectors per track (numbered as 0,
1, … 255). The following 6 disk requests of the form [sector number, cylinder
number, platter number] are received by the disk controller at the same time:
[120, 72, 2], [180, 134, 1], [60, 20, 0], [212, 86, 3], [56, 116, 2], [118, 16, 1]
Currently head is positioned at sector number 100 of cylinder 80, and is moving
towards higher cylinder numbers. The average power dissipation in moving the
head over 100 cylinders is 20 milliwatts and for reversing the direction of the
head movement once is 15 milliwatts. Power dissipation associated with
rotational latency and switching of head between different platters is negligible.
The total power consumption in milliwatts to satisfy all of the above disk
requests using the Shortest Seek Time First disk scheduling algorithm is ______ .
[GATE 2018]
NVV’s 58
Answer

NVV’s 59
Answer

Total Head movements in SSTF = (86-80) + (86-72) + (134-72) +


(134-16) = 200
Power dissipated by 200 movements : P1 = 0.2 * 200 = 40 mW
Power dissipated in reversing head direction once = 15 mW
Number of time Head changes its direction = 3
Power dissipated in reversing head direction: P2 = 3 * 15 = 45 mW
Total power consumption (in mW) is P1 + P2 = 40 mW + 45 mW
= 85 mW
So, answer is 85.

NVV’s 60
• Q2. Consider a disk queue with requests for I/O to blocks on cylinders
47,38,121,191,87,11,92,10. The C-LOOK scheduling algorithm is used.
The head is initially at cylinder number 63 moving towards larger
cylinder numbers on its servicing pass. The cylinders are numbered from
0 to 199 The total head movement (in number of cylinders) incurred
while servicing these requests is --------
• GATE 2016

NVV’s 61
Q3 :
Consider the following five disk access requests of the form (request id,
cylinder number) that are present in the disk scheduler queue at a given
time.
(P, 155), (Q, 85), (R, 110), (S, 30), (T, 115)
Assume the head is positioned at cylinder 100. The scheduler follows
Shortest Seek Time First scheduling to service the requests.
Which one of the following statements is FALSE?[GATE 2020]
The head reverses its direction of movement between
A
servicing of Q and P.
B T is serviced before P.
C R is serviced before P.
D Q is serviced after S, but before T.

D Q is serviced after S, but before T.


NVV’s 62
NVV’s 63

You might also like