Unit6: Secondary-Storage Structures
Secondary Storage Structure
Disk is secondary storage that is used to store data
The data is provided to user programs by means of I/O requests.
Disk Structure
Disk is divided into tracks cylinder and sectors.
Data is stored on series of magnetic disks called Platters,
connected by spindle.
Surface of platter is divided into circular rings called Tracks
Tracks are divided into Sectors.
Sectors are of fixed sized.
Tracks are one arm position form a cylinder.
Secondary Storage Structure
Storage Devices can be categorized in to 3 types:
1. Random Access Memory
2. Serial Storage Device
The data is written on tape.
Data is read in a serial / sequential manner
Exp: Magnetic Tape
3. Direct Access Storage
Exp: Magnetic Disk
Floppy disk
CD etc.
Disk Surface
Moving-head Disk Machanism
Mass Storage Structure
Seek Time: It is the time required to move a head to the
required track.
Latency Time: It is the amount of time it takes the portion of
disk on which data record is stored to spin under read/write
head.
Transfer time: time spent in actually moving data to from the
disk surface.
It is amount of information to be read, the number of bytes per track
and rotation speed.
Total Access Time: it is Seek time + Latency Time + Transfer Time
Disk Scheduling
Scheduling is mechanism of arranging requests in order to save un-necessary rotations
by disk arm and disk pointer.
OS takes I/O requests from queue and process them one by one. Algo. used to select
which I/O request is going to be selected first is called Disk Scheduling
Algorithm
Objective:
1. Minimize response time
2. Maximize Throughput.
Response Time: Avg. time that a request must wait before it is satisfied
Throughput: Avg. number of requests satisfied per unit of time.
Disk Scheduling Algo.
1. FCFS
Access the data block as it is requested.
Example: A disk size of 200 tracks receives the requests for the blocks for
I/O operation. No. of blocks requested on disk are:
98, 183, 37, 122, 14, 124, 65, 67
Head pointer/ Disk arm is at 53. Find head movements.
FCFS
Illustration shows total head movement of 640 cylinders.
FCFS
Total Head Movements:
|53-98| + |98-183| + |183- 37| + | 37-122| + |122-14| + |14-124| +
|124-65| + |65-67|
= 640
SSTF- Shortest Seek Time First
Selects the request with the minimum seek
time from the current head position.
SSTF scheduling is a form of SJF scheduling; may
cause starvation of some requests.
SSTF (Cont.)
5) 53-98=45
8) 53-183=130
3) 53-37=16
6)53-122=69
4)53-14=39
7) 53-124=71
1)53-65=12
2)53-67=14
Find total head
movement
SSTF- Shortest Seek Time First (H.W.)
Exp: 23,89,132,42,187,60. Disk head is at position 100
Find total head movements.
Hint: 241
SCAN
The disk arm starts at one end of the disk and moves toward the other
end, servicing requests until it gets to the other end of the disk, where the
head movement is reversed and servicing continues.
A request arriving behind the head will have to wait until the arm moves to
the end of the disk, reverses direction, and comes back.
Sometimes called the elevator algorithm.
Example: Previously head is at 60. so from 60, we go to 53 i.e left
But if previously if the head is at 5 then the direction will be towards
the right. By default: left direction.
SCAN
Previous R/W head position is 65
the total head movement of ______cylinders.
SCAN
Advantage
Throughput is better than FCFS
If a request arrive in a queue just in front of the
head, it will be serviced immediately.
Disadvantage:
The disk arm always starts from the beginning, no
matter other number of requests are present on
the other end of disk.
C-Scan
It is an enhancement of SCAN algorithm.
Head moves from one end of disk to the other servicing the
request along the way.
When the disk arm reaches the end it quickly returns to the
other end without fulfilling any request in the way
It restricts servicing request from one direction only.
It will move in increasing order of cylinder number.
Head will go to extreme ends.
Move towards increasing the direction of cylinder
number requests
C-Scan Example
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Direction = right (given: We are moving from left to right)
C-Scan
Suppose a disk is having 200 cylinder from 0 to 199.
disk is currently searching for disk head 53.
previous request was at head 60. the queue of
pending request is in FIFO order.
98,183,37,122,14,124,65,67.
Find total head movements.
Ans:183
LOOK or C-LOOK
Same as SCAN
Arm Does not go to end.
Will not go beyond max(1.e 183) and beyond min(i.e. 14)
Arm only goes as far as the final request in each direction,
Then it reverses direction immediately, without first going all the
way to the end of the disk.
LOOK
Total head movements: 208
C- LOOK
Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}
Initial head position = 50
Direction = right (Moving from left to right)
Selecting a Disk-Scheduling Algorithm
SSTF is common and has a natural appeal
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.
The disk-scheduling algorithm should be written as a separate
module of the operating system, allowing it to be replaced with a
different algorithm if necessary.
Either SSTF or LOOK is a reasonable choice for the default
algorithm.