You are on page 1of 19

Chapter 11

Mass Storage Management

Dr. Niroj Kumar Pani


nirojpani@gmail.com

Department of Computer Science Engineering & Applications


Indira Gandhi Institute of Technology
Sarang, Odisha
Chapter Outline…
◼ Disk Structure

◼ Disk Scheduling

◼ Disk Management

◼ Swap-Space Management

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.2


Disk Structure
◼ Hardware Structure of a Disk:
➢ Surface of the disk is called a disk platter.
➢ Each platter is divided into tracks.
➢ Each track is divided into sectors.

◼ Data Transfer Between Primary Memory & Disk:


➢ Data transfer always takes place in terms of blocks (of data).
➢ Disk drives are addressed as large 1-dimensional arrays of logical
blocks, where the logical blocks is mapped into the sectors of the disk
sequentially.
➢ Mapping proceeds with the 1st sector of 1st track, then in order through
that track, then the rest of the tracks in that cylinder, and then through
the rest of the cylinders from outermost to innermost

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.3


Disk Scheduling
◼ The Issue (Meaning of Disk Scheduling):
➢ How the data in a disk will be retrieved so the access time will be
minimum?

◼ Some Important Terms Related to Disk Scheduling:


1. Access Time: It is the addition of seek time and rotational latency /
latency time.
2. Seek Time: It is the time for the disk arm to move the read-write head to
the cylinder containing the desired sector.
3. Rotational Latency / Latency Time: It is the time required for the disk to
rotate the desired sector to the read-write head.
4. Disk Bandwidth: It is the total number of bytes transferred, divided by
the total time between the first request for service and the completion of
the last transfer

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.4


◼ Disk Scheduling Algorithms:
1. FCFS (First-Come-First-Serve) Disk Scheduling

2. SSTF (Shortest-Seek-Time-First) Disk Scheduling

3. SCAN Disk Scheduling

4. C-SCAN Disk Scheduling

5. LOOK Disk Scheduling

6. C-LOOK Disk Scheduling

We illustrate these algorithms with the following cylinder request queue.

98, 183, 37, 122, 14, 124, 65, 67

We assume that the cylinder range is 0-199 and the head pointer is at
cylinder 53.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.5


FCFS

◼ The Rule: Select / serve the cylinder request that has arrived first.

◼ Example:

Total head movement =


(98-53)+(183-98)+(183-37)
+(122-37)+(122-14)+(124-
14)+(124-65)+(67-65) =
640 cylinders.

[Fig. 11.1: Head movement in FCFS Algorithm]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.6


SSTF (Shortest-Seek-Time-First)

◼ The Rule: Select / serve the request with the minimum seek time from the
current head position.

◼ Example:

Total head movement =


(65-53)+(67-65)+(67-
37)+(37-14)+(98-14)+(122-
98)+(124-122)+(183-124) =
236 cylinders.

[Fig. 11.2: Head movement in SSTF Algorithm]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.7


◼ Analysis:
➢ SSTF scheduling is a form of SJF scheduling
➢ It may cause starvation of some requests.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.8


SCAN (Also called Elevator Algorithm)

◼ The Rule: The head moves in one direction (either forward or backward
depending upon the current direction of the head movement) up to one end of
the disc, and then in reverse direction up to the other end of the disc, serving
the requests in its path. This process continues.

◼ Example: Total head movement =


(199-53)+(199-14) = 331
cylinders.

[NOTE]: Here, in the question,


since no information is given on
the direction of the head
movement it by default assumed
to be in the forward direction (i.e.,
0 to 199).
[Fig. 11.3: Head movement in SCAN Algorithm]
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.9
C-SCAN (Circular SCAN)

◼ The Rule: The head moves in forward direction (0 to max) up to the end of the
disc serving the requests in its path. However, on reaching the end, the head
immediately returns to the beginning of the disc, without serving any requests
in the reverse path. The serving again continues in forward direction from the
beginning of the disc. This process continues.

◼ Example:

Total head movement =


(199-53)+(199-0)+(37-0) = 382
cylinders.

[Fig. 11.4: Head movement in


C-SCAN Algorithm]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.10


LOOK

◼ The Rule: The head moves in one direction (either forward or backward
depending upon the current direction of the head movement), and then in
reverse direction of the disc up to the final requests in each direction, serving
the requests in its path. This process continues.

◼ Example:

Total head movement =


(183-53)+(183-14) = 299
cylinders.

[Fig. 11.5: Head movement in LOOK Algorithm]


Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.11
C-LOOK (Circular LOOK)

◼ The Rule: The head moves in forward direction (0 to max) of the disc up to the
final request in that direction serving the requests in its path. However, on
reaching the final request, the head immediately returns to the final request in
backward direction of the disc, without serving any requests in the reverse
path. The serving again continues in forward direction from the beginning of
the disc. This process continues.

◼ Example:

Total head movement = (183-


53)+(183-14)+(37-14) = 322
cylinders.

[Fig. 11.6: Head movement in


C-LOOK Algorithm]

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.12


Selecting a Disk-Scheduling Algorithm

◼ SSTF is common and has a natural appeal.

◼ SCAN and C-SCAN perform better for systems that place a heavy load on the
disk.

◼ Performance depends on the number and types of requests.

◼ Requests for disk service can be influenced by the file-allocation method.

◼ Either SSTF or LOOK is a reasonable choice for the default algorithm.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.13


Disk Management
◼ Activities under disk management includes:
➢ Disk formatting / disk initialization
➢ Booting form disk
➢ Bad block recovery

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.14


Disk Formatting

◼ A disk just after being manufactured is a blank palter of magnetic material.

◼ Before a disk can store any data, it need to be divided into sectors. This
process is called low-level formatting / physical formatting. Most hard disks are
low-level formatted at the factory as a part of the manufacturing process.

◼ To use a disk to hold files the OS need to partition the disk (i.e. the disk is
divided into one or more groups of cylinders). The OS may consider each
partition as a separate disk. For instance one partition may hold a copy of the
OS executables, while another holds user files.

◼ After partitioning the last step is logical formatting. In this step the OS stores
the initial file system (for example FAT) on to the disk.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.15


Booting form Disk

◼ When the computer is switched-on it need an initial program to start running.


This program is called bootstrap program.

◼ The Issue: Where to store the bootstrap?

➢ Approach 1: Store it in ROM. It has the disadvantage that changing the


bootstrap code requires changing the ROM.

➢ Approach 2 (Commonly used): Store a tiny bootstrap loader program in


ROM. Its only task is to bring the full bootstrap program that is stored in
a fixed location on the disc.

[NOTE]: The fixed part of the disk where the full bootstrap program is stored is called
boot block. The disk that has a boot block is called a boot disk / system disk.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.16


Bad Block Recovery

◼ What is a bad block?: A group of defective sectors is called a bad block. Most
disks even come from factory with bad blocks in it.

◼ Bad block recovery techniques:

1. MS-Dos during logical formatting writes a special value in its FAT entry
for each bad blocks.

2. Sector sparing / forwarding

3. Sector Slipping

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.17


Swap Space Management
◼ Swap Space: Why & What?:
➢ Virtual memory technique uses disk space as an extension of main
memory. The main goal for design and implementation of swap space is
to provide best throughput for the virtual memory system.
➢ Swap-space can be carved out of the normal file system, or, more
commonly, it can be in a separate disk partition.

◼ Different OS uses different swap space management techniques:


➢ 4.3BSD allocates swap space when process starts; holds text segment
(the program) and data segment. Kernel uses swap maps to track swap-
space use.
➢ Solaris 2 allocates swap space only when a page is forced out of
physical memory, not when the virtual memory page is first created.

Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 11.18


End of Chapter 11

You might also like