Download as pdf or txt
Download as pdf or txt
You are on page 1of 84

STORAGE MANAGEMENT

(UNIT V)

Dr. Indrajeet Kumar


Department of CSE
Graphic Era Hill University
Dehradun
Secondary Storage
• Secondary storage devices are those
devices whose memory is non volatile,
means the stored data will be intact even if
the system is turned off.
• Secondary storage is also called auxiliary
storage.
• Secondary storage is less expensive when
compared to primary memory like RAMs.
• The speed of the secondary storage is
also lesser than that of primary storage.

• Hence, the data which is less frequently


accessed is kept in the secondary storage.

• Examples: magnetic disks, magnetic


tapes, removable thumb drives etc.
Magnetic Disk Structure
• A magnetic disk contains several platters.
• Each platter is divided into circular shaped
tracks.
• The length of the tracks near the centre is
less than the length of the tracks farther
from the centre.
• Each track is further divided into sectors.
• The point to be noted here is that outer
tracks are bigger in size than the inner
tracks but they contain the same number
of sectors and have equal storage
capacity.
• Some space of every sector is used for
formatting. So, the actual capacity of a
sector is less than the given capacity.
• Read-Write(R-W) head moves over the
rotating hard disk.
• Read-Write head that performs all the read
and write operations on the disk and
hence, position of the R-W head is a major
concern.

• To perform a read or write operation on a


memory location, we need to place the R-
W head over that position.
• Seek time – The time taken by the R-W head to
reach the desired track from it’s current position.
• Rotational latency – Time taken by the sector to
come under the R-W head.
• Data transfer time – Time taken to transfer the
required amount of data. It depends upon the
rotational speed.
• Controller time – The processing time taken by the
controller.
• Average Access time – seek time + Average
Rotational latency + data transfer time + controller
time.
• Note: Average Rotational latency is mostly
1/2*(Rotetional latency).
• In questions, if the seek time and controller time is not
mentioned, take them to be zero.
• If the amount of data to be transferred is not given,
assume that no data is being transferred. Otherwise,
calculate the time taken to transfer the given amount
of data.
• The average of rotational latency is taken when the
current position of R-W head is not given.
• Because, the R-W may be already present at the
desired position or it might take a whole rotation to get
the desired sector under the R-W head.
• But, if the current position of the R-W head is given
then the rotational latency must be calculated.
• Example –
Consider a hard disk with:
4 surfaces
64 tracks/surface
128 sectors/track
256 bytes/sector
• What is the capacity of the hard disk?
Disk capacity = surfaces * tracks/surface *
sectors/track * bytes/sector
Disk capacity = 4 * 64 * 128 * 256
Disk capacity = 8 MB
• The disk is rotating at 3600 RPM, what is
the data transfer rate?
60 sec -> 3600 rotations
1 sec -> 60 rotations
Data transfer rate = number of rotations
per second * track capacity * number of
surfaces (since 1 R-W head is used for
each surface)
Data transfer rate = 60 * 128 * 256 * 4
Data transfer rate = 7.5 MB/sec
• The disk is rotating at 3600 RPM, what is the
average access time?
Since, seek time, controller time and the amount of
data to be transferred is not given, we consider all
the three terms as 0.
Therefore, Average Access time = Average
rotational delay
Rotational latency => 60 sec -> 3600 rotations
1 sec -> 60 rotations
Rotational latency = (1/60) sec = 16.67 msec.
Average Rotational latency = (16.67)/2
= 8.33 msec.
Average Access time = 8.33 msec.
Disk Scheduling Algorithms

• 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.
Various disk scheduling algorithms are-
– FCFS Algorithm
– SSTF Algorithm
– SCAN Algorithm
– C-SCAN Algorithm
– LOOK Algorithm
– C-LOOK Algorithm
FCFS Disk Scheduling Algorithm

• As the name suggests, this algorithm


entertains requests in the order they arrive
in the disk queue.

• It is the simplest disk scheduling 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.
PRACTICE PROBLEM
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. The total head
movement (in number of cylinders)
incurred while servicing these requests is
_______.
Sol: 98, 183, 41, 122, 14, 124, 65, 67
Total head movements incurred while
servicing these requests
= (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
SSTF Disk Scheduling Algorithm
• SSTF stands for Shortest Seek Time
First.
• This algorithm services that request next
which requires least number of head
movements from its current position
regardless of the direction.
• It breaks the tie in the direction of head
movement.
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.
• It provides high variance in response time
and waiting time.
• Switching the direction of head frequently
slows down the algorithm.
Problem: 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 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
_______.
Sol: 98, 183, 41, 122, 14, 124, 65, 67
Total head movements incurred while
servicing these requests
= (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
SCAN Disk Scheduling Algorithm
• As the name suggests, this algorithm scans
all the cylinders of 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.
NOTE-
• SCAN Algorithm is also called as Elevator
Algorithm.

• This is because its working resembles the


working of an elevator.
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.
Problem: 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 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
_______.
Total head movements incurred while
servicing these requests
= (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
C-SCAN Disk Scheduling Algorithm
• 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.
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.
Problem: 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
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
_______.
Total head movements incurred while
servicing these requests
= (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
LOOK Disk Scheduling Algorithm
• 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.
NOTE-
• 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.
Advantages:
• It does not causes 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.
• 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 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 _______.
Total head movements incurred while
servicing these requests
= (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
C-LOOK Disk Scheduling Algorithm
• 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.
Advantages-
• It does not causes 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.
• 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 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 _______.
Total head movements incurred while
servicing these requests
= (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
File-System Structure
• File structure
– Logical storage unit
– Collection of related information
• File system organized into layers
• File system resides on secondary storage (disks)
– Provides efficient and convenient access to disk by
allowing data to be stored, located retrieved easily
• File control block – storage structure consisting of
information about a file
• Device driver controls the physical device
Layered File System
File Concept
• A file is a named collection of related
information that is recorded on secondary
storage such as magnetic disks, magnetic
tapes and optical disks. In general, a file is
a sequence of bits, bytes, lines or records
whose meaning is defined by the files
creator and user.
• A file has a certain defined structure
according to its type
• A text file is a sequence of characters
organized into lines.
• A source file is a sequence of procedures
and functions.
• An object file is a sequence of bytes
organized into blocks that are
understandable by the machine.
• When operating system defines different
file structures, it also contains the code to
support these file structure. Unix, MS-DOS
support minimum number of file structure.
File Type

• File type refers to the ability of the


operating system to distinguish different
types of file such as text files source files
and binary files etc.

• Many operating systems support many


types of files.
• Operating system like MS-DOS and UNIX
have the following types of files −
– Ordinary files

– Directory files

– Special files
Ordinary files
• These are the files that contain user
information.

• These may have text, databases or


executable program.

• The user can apply various operations on


such files like add, modify, delete or even
remove the entire file.
Directory files

• These files contain list of file names and


other information related to these files.
Special files
• These files are also known as device files.
• These files represent physical device like
disks, terminals, printers, networks, tape
drive etc.
• These files are of two types −
– Character special files − data is handled
character by
– character as in case of terminals or printers.
– Block special files − data is handled in blocks
as in the case of disks and tapes.
File Access Mechanisms
• File access mechanism refers to the
manner in which the records of a file may
be accessed.

• There are several ways to access files −


– Sequential access

– Direct/Random access

– Indexed sequential access


Sequential access
• A sequential access is that in which the
records are accessed in some sequence,
i.e., the information in the file is processed
in order, one record after the other. This
access method is the most primitive one.
Example: Compilers usually access files in
this fashion.
Direct/Random access
• Random access file organization provides,
accessing the records directly.
• Each record has its own address on the
file with by the help of which it can be
directly accessed for reading or writing.
• The records need not be in any sequence
within the file and they need not be in
adjacent locations on the storage medium.
Indexed sequential access
• This mechanism is built up on base of
sequential access.

• An index is created for each file which


contains pointers to various blocks.

• Index is searched sequentially and its


pointer is used to access the file directly.
Space Allocation Methods
• An allocation method refers to how disk
blocks are allocated for files:

– Contiguous allocation

– Linked allocation

– Indexed allocation
Contiguous Allocation
• Each file occupies a contiguous address space
on disk.

• Assigned disk address is in linear order.

• Easy to implement.

• External fragmentation is a major issue with this


type of allocation technique.
Contiguous Allocation of Disk Space
Linked Allocation
• Each file carries a list of links to disk
blocks.

• Directory contains link / pointer to first


block of a file.

• No external fragmentation

• Effectively used in sequential access file.

• Inefficient in case of direct access file.


Linked Allocation
File-Allocation Table
Indexed Allocation
• Provides solutions to problems of contiguous and
linked allocation.

• A index block is created having all pointers to


files.

• Each file has its own index block which stores the
addresses of disk space occupied by the file.

• Directory contains the addresses of index blocks


of files.
Example of Indexed Allocation
Structures of Directory
• A directory is a container that is used to
contain folders and file.
• It organizes files and folders into a
hierarchical manner.
• There are several logical structures of a
directory, these are given below.
– Single-level directory
– Two-level directory
– Tree-structured directory
– Acyclic graph directory
Single-level directory
• Single level directory is simplest directory
structure. In it all files are contained in
same directory which make it easy to
support and understand.
• A single level directory has a significant
limitation, however, when the number of
files increases or when the system has
more than one user.
• Since all the files are in the same
directory, they must have the unique
name.
• If two users call their dataset test, then the
unique name rule violated.
Two-level directory
• As we have seen, a single level directory
often leads to confusion of files names
among different users.

• The solution to this problem is to create a


separate directory for each user.
• In the two-level directory structure, each
user has there own user files directory
(UFD).
• The UFDs has similar structures, but each
lists only the files of a single user.
• System’s master file directory (MFD) is
searches whenever a new user id’s logged
in.
• The MFD is indexed by username or
account number, and each entry points to
the UFD for that user.
Tree-structured directory
• Once we have seen a two-level directory as a tree of
height 2, the natural generalization is to extend the
directory structure to a tree of arbitrary height.

• This generalization allows the user to create there own


subdirectories and to organize on their files accordingly.

• A tree structure is the most common directory structure.


The tree has a root directory, and every file in the system
have a unique path.
Acyclic graph directory
• Acyclic: not displaying or forming part of a
cycle, containing no rings of atoms.

• An acyclic graph is a graph with no cycle


and allows to share subdirectories and
files.

• The same file or subdirectories may be in


two different directories.
• It is a natural generalization of the tree-
structured directory.

• It is used in the situation like when two


programmers are working on a joint
project and they need to access files.
Thank you

You might also like