0% found this document useful (0 votes)
130 views56 pages

Secondary Storage Devices (1) :: Magnetic Disks

The document discusses secondary storage devices, specifically magnetic disks. It explains that magnetic disks store data on circular platters called disks that rapidly rotate. A disk head reads and writes bits of data as they pass underneath on tracks divided into sectors, which are the smallest addressable units. Disks are organized into cylinders that allow accessing all tracks without moving the disk arm.

Uploaded by

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

Secondary Storage Devices (1) :: Magnetic Disks

The document discusses secondary storage devices, specifically magnetic disks. It explains that magnetic disks store data on circular platters called disks that rapidly rotate. A disk head reads and writes bits of data as they pass underneath on tracks divided into sectors, which are the smallest addressable units. Disks are organized into cylinders that allow accessing all tracks without moving the disk arm.

Uploaded by

Samahir Alkleefa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 56

Secondary Storage Devices(1):

Magnetic Disks

Adil Yousif , PhD

Lecture 2
Secondary Storage Devices

 Two major types of secondary storage devices:


1. Direct Access Storage Devices (DASDs)
 Magnetic Discs
Hard disks (high capacity, low cost, fast)
Floppy disks (low capacity, lower cost, slow)
 Optical Disks
CD-ROM = (Compact disc, read-only memory
2. Serial Devices
 Magnetic tapes (very fast sequential access)

2
Storage and Files
 Storage has major implications for DBMS design!
 READ: transfer data from disk to main memory (RAM).
 WRITE: transfer data from RAM to disk.
 Both operations are high-cost operations, relative to in-
memory operations, so DB must be planned carefully!
 Why Not Store Everything in Main Memory?
 Costs too much: Cost of RAM about 100 times the cost of the
same amount of disk space, so relatively small size.
 Main memory is volatile.
 Typical storage hierarchy:
 Main memory (RAM) (primary storage) for currently
used data.
 Disk for the main database (secondary storage).
 Tapes for archiving older versions of the data (tertiary
storage).
3
Sstorage Hhierarchy

 Pprimary storage : random access memory (RAM)


 typical capacity a number of GB
 cost per MB $2-3.00

 typical access time 5ns to 60ns

 Ssecondary storage: magnetic disk/ optical devices/


tape systems
 typical capacity a number of 100GB for fixed media;
 for removable
 cost per MB $0.01 for fixed media, a little more for
removable
 typical access time 8ms to 12ms for fixed media,
larger for removable
4
Units of Measurement
Spatial units:
o  byte: 8 bits
o  kilobyte (KB): 1024 or 210 bytes
o  megabyte (MB): 1024 kilobytes or 220 bytes
o  gigabyte (GB): 1024 megabytes or 230 bytes
Time units:
o  nanosecond (ns) one- billionth (10-9 ) of a second
o  microsecond ( s) one- millionth (10-6 ) of a second
o  millisecond (ms) one- thousandth (10-3 ) of a second
Primary versus Secondary Storage
 Primary storage costs several hundred times as much
per unit as secondary storage, but has access times that
are 250,000 to 1,000,000 times faster than secondary
storage.
5
Memory Hierarchy

 At the primary storage level, the memory hierarchy


includes, at the most expensive end’ cache memory,
which is a static RAM (Random Access Memory).
 The next level of primary storage is DRAM (Dynamic
RAM), The advantage of DRAM is its low cost, lower
speed compared with static RAM.
 Programs normally reside and execute in DRAM.

 Now that personal computers and workstations have


tens of gigabytes of data in DRAM, in some cases,
entire databases can be kept in the main memory
(with a backup copy on magnetic disk), leading to
main memory databases.
6
Memory Hierarchy-flash memory

 Flash memory, since 1988 it has become common,


particularly because it is nonvolatile, using EEPROM
(Electrically Erasable Programmable Read-Only
Memory) technology.
 Its life is 10,000-1,000,000 times erase… Read/write is
fast, but erase is slow…
 Therefore special arrangements are made for the file
system, regarding file delete or update.
 Capacities up to 128 GB has been realized todate.

7
Magnetic Disks

Bits of data (0’s and 1’s) are stored on circular


magnetic platters called disks.
A disk rotates rapidly (& never stops).
A disk head reads and writes bits of data as they
pass under the head.
Often, several platters are organized into a disk
pack (or disk drive).

8
A Disk Drive

surfaces

Spindle Boom

Read/Write heads

Disk drive with 4 platters and 8 surfaces and 8 RW heads


9
Looking at a surface

tracks

sector

Surface of disk showing tracks and sectors

10
Organization of Disks

Disk contains concentric tracks.


Tracks are divided into sectors
A sector is the smallest addressable unit in a
disk.

11
Components of a Disk
Spindle
Tracks
Disk head
 The platters spin (say, 90rps).
The arm assembly is moved in or out
to position a head on a desired track. Sector
Tracks under heads make a cylinder
(imaginary!).

Platters
 Only one head reads/writes Arm movement
at any one time.

Block size is a multiple Arm assembly



of sector size (which is often fixed).

12
Disk Controller
Disk controllers: typically embedded
in the disk drive, which acts as an
interface between the CPU and the
disk hardware.

The controller has an internal


cache (typically a number of MBs)
that it uses to buffer data for
read/write requests.
13
Accessing Data

When a program reads a byte from the disk, the


operating system locates the surface, track and
sector containing that byte, and reads the entire
sector into a special area in main memory called
buffer.
The bottleneck of a disk access is moving the
read/write arm.
 So it makes sense to store a file in tracks that are
below/above each other on different surfaces, rather than
in several tracks on the same surface.

14
Cylinders
A cylinder is the set of tracks at a given radius of a
disk pack.
 i.e. a cylinder is the set of tracks that can be accessed without
moving the disk arm.
All the information on a cylinder can be accessed
without moving the read/write arm.

15
Cylinders

16
Estimating Capacities

Track capacity = # of sectors/track * bytes/sector


Cylinder capacity = # of tracks/# of cylinder * track
capacity
Drive capacity = # of cylinders * cylinder capacity
Number of cylinders = # of tracks on a surface

17
Exercise

Store a file of 20000 records on a disk with the


following characteristics:
# of bytes per sector = 512
# of sectors per track = 40
# of tracks per cylinder = 11
# of cylinders = 1331
Q1. How many cylinders does the file require if each
data record requires 256 bytes?
Q2. What is the total capacity of the above disk?

18
Organizing Tracks by sector

6 10
7 3
5 6

4 8 2 7

3 9 9 11

2 5
10 4
1 11 1 8

Physically adjacent Sectors with 3:1 interleaving


sectors

19
Exercise
 Suppose we want to read consecutively the
sectors of a track in order: sectors 1, 2,…11.
 How many revolutions to read the disk?
a) Without interleaving
b) With 3:1 interleaving
 Note: nowadays most disk controllers are
fast enough so interleaving is not common...

20
Cluster, Extent, and Fragmentation
 The file manager is the part of the operating system responsible
for managing files.it maps the logical parts of the file into their
physical location .
►A cluster is a fixed number of contiguous sectors
►The file manager allocates an integer number of clusters to a file.
An example: Sector size: 512 bytes,
Cluster size: 2 sectors
– If a file contains 10 bytes, a cluster is allocated (1024 bytes).
– There may be unused space in the last cluster of a file.
This unused space contributes to internal fragmentation

21
Extents
If there is a lot of room on a disk, it may be
possible to make a file consist entirely of
contiguous clusters.
 Then we say that the file is one extent. (very
good for sequential processing)
If there isn’t enough contiguous space available
to contain an entire file, the file is divided into
two or more noncontiguous parts. Each part is a
separate extent.

22
Fragmentation
►Due to records not fitting exactly in a sector
– Example: Record size = 200 bytes, sector size = 512 bytes
– to avoid that a record span 2 sectors we can only store 2
records in this sector (112 bytes go unused per sector
– the alternative is to let a record span two sectors, but in
this case two sectors must be read when we need to
access this record)
►Due to the use of clusters
– If the file size is not multiple of the cluster size, then the
last cluster will be partially used. 23
Organizing Tracks by Block
 Disk tracks may be divided into user-defined blocks
rather than into sectors.
 Blocks can be fixed or variable length.
 A block is usually organized to hold an integral number
of logical records.
 Blocking Factor = number of records stored in a
block.
 No internal fragmentation, no record spanning over two
blocks.
 In block-addressing scheme each block of data may be
accompanied by one or more subblocks containing extra
information about the block: record count, last record
key on the block…

24
How to Choose Cluster Size

Some OS allow the system administrator to choose


the cluster size.
►When to use large cluster size?
– When disks contain large files likely to be processed
sequentially.
– Example: Updates in a master file of bank accounts (in batch mode).
►What about small cluster size?
– When disks contain small files and/or files likely to be accessed
randomly
– Example : online updates for airline reservation

25
Non-data Overhead
Both blocks and sectors require non-data overhead
(written during formatting)
On sector addressable disks, this information
involves sector address, track address, and
condition (usable/defective). Also pre-formatting
involves placing gaps and synchronization marks
between the sectors.
Where a block may be of any size, more
information is needed and the programmer should
be aware of some of this information to utilize it for
better efficiency…
26
Example

 Disk characteristics
– Block-addressable Disk Drive
– Size of track = 20.000 bytes
– Nondata overhead per block = 300 bytes
► File Characteristics
– Record size = 100 bytes
► How many records can be stored per track for the
following blocking factors?
1. Block factor = 10
2. Block factor = 60
27
Solution
 Blocking factor is 10
►Size of data block = 1000
Size of data block+ sublock= 1300
►Number of blocks that can fit in a track =

►Number of records per track = 150 records

28
Solution

 Blocking factor is 60
►Size of data blocks+ subblocks = 6300
►Number of blocks that can fit in a track =

Number of records per track = 180 records

Larger blocking factor leads to efficient use of storage

29
The Cost of a Disk Access
 The time to access a sector in a track on a surface is divided into 3
components:

Time Component Action


Seek Time Time to move the read/write arm to
the correct cylinder
Rotational delay (or Time it takes for the disk to rotate so
latency) that the desired sector is under the
read/write head
Transfer time Once the read/write head is
positioned over the data, this is the
time it takes for transferring data
30
Seek time

Seek time is the time required to move the arm to


the correct cylinder.
Largest in cost.
Typically:
 5 ms (miliseconds) to move from one track to the next
(track-to-track)
 50 ms maximum (from inside track to outside track)

 30 ms average (from one random track to another


random track)

31
Average Seek Time (s)-1

 It is usually impossible to know exactly how many


tracks will be traversed in every seek,
 we usually try to determine the average seek time (s)
required for a particular file operation.
 If the starting positions for each access are random, it
turns out that the average seek traverses one third
of the total number of cylinders.
 There are more ways to travel short distance than to travel
long distance…
 Manufacturer’s specifications for disk drives often list
this figure as the average seek time for the drives.
 Most hard disks today have s under 10 ms, and high-
performance disks have s as low as 7.5 ms.

32
Average Seek Time (s)-2
Seek time depends only on the speed with
which the head rack moves, and the number of
tracks that the head must move across to
reach its target.
Given the following (which are constant for a
particular disk):
 Hs = the time for the I/ O head to start moving
 Ht = the time for the I/ O head to move from one
track to the next
Then the time for the head to move n tracks is:
Seek(n)= Hs+ Ht*n

33
Rotational Latency(latency)-1
Latency is the time needed for the disk to rotate so
the sector we want is under the read/write head.
Hard disks usually rotate at about 5000-7000
rpm,
 12-8 msec per revolution.
 Eg. for 7200 rpm, max latency is 8.33 msec.
Note:
 Min latency = 0
 Max latency = Time for one disk revolution
 Average latency (r) = (min + max) / 2
= max / 2
= time for ½ disk revolution
 Typically 6 – 4 ms, at average

34
Rotational Latency computation-2

Given the following:


 R = the rotational speed of the spindle (in rotations per
second)
  = the number of radians through which the track must rotate
 then the rotational latency  radians is:
Latency= (/2)*(1000/R), in ms

35
Transfer Time-1

Transfer time is the time for the read/write head to


pass over a block.
The transfer time is given by the formula:
number of sectors
Transfer time = --------------------------------- x rotation
time
track capacity in number of sectors

 e.g. if there are St sectors per track, the time to transfer one
sector would be 1/ St of a revolution.

36
Transfer Time-2

The transfer time depends only on the speed at


which the spindle rotates, and the number of sectors
that must be read.
Given:
 St = the total number of sectors per track
 the transfer time for n contiguous sectors on the same track
is:
Transfer Time =(n/St)*(1000/R), in ms

37
Exercise

Given the following disk:


 20 surfaces
800 tracks/surface
25 sectors/track
512 bytes/sector
 3600 rpm (revolutions per minute)
 7 ms track-to-track seek time
28 ms avg. seek time
50 ms max seek time.
Find:
a) Disk capacity in bytes
b) Maximum and Average latencies
c) Total time to read the entire disk, one cylinder at a time

38
Parameters of Disks(The Cost of a disk Access)
1- Seek time (s)
This is the time needed to mechanically position the read/write
head on the correct track for movable-head disks.
 For fixed-head disks, it is the time needed to electronically
switch to the appropriate read/write head.
For 1ST Type, this time varies, depending on the distance
between the current track under the r/w head and the track
specified in the block address. Usually, the disk manufacturer
provides an average seek time in milliseconds.
The typical range of average seek time is 4 to 10 msec.
This is the main culprit for the delay involved in transferring
blocks between disk and memory.
2-Rotational delay (rd)

Once the read/write head is at the correct track, the


user must wait for the beginning of the required block
(sector)to rotate into position under the read/write
head.
On average, this takes about the time for half a
revolution of the disk, but it actually ranges from
immediate access (if the start of the required block is
in position under the read/write head right after the
seek) to a full disk revolution (if the start of the
required block just passed the read/write head after
the seek).
2-Rotational delay (rd) cont.
If the speed of disk rotation is p revolutions per minute
(rpm), then the average rotational delay rd is given by:
rd = (1/2) * (1/p) min = (60 * 1000)/(2 * p) msec = 30000/p
msec
A typical value for p is 10,000 rpm, which gives a
rotational delay of rd = 3
Block transfer time (btt)
 Once the read/write head is at the beginning of the required
block, some time is needed to transfer the data in the block.
 Block transfer time(btt) depends on the block size, track size,
and rotational speed.
 If the transfer rate for the disk is tr bytes/msec and the block
size is B bytes, then:
btt = B/tr msec
 If we have a track size of 50 Kbytes and p is 3600 rpm, then
the transfer rate in bytes/msec is
tr = (50 * 1000)/(60 * 1000/3600) = 3000 bytes/msec
 In this case, btt = B/3000 msec, where B is the block size in
bytes.
The Cost of a disk Access

The average time (s) needed to find and transfer a block,


given its block address, is estimated by:
(s + rd + btt) msec
Transfer time for disks organized by sectors

Transfer time = revolution time / #sectors per track


Example

Disk characteristics :
Average seek time=8msec
Average rotational delay=
3msec
Maximum rotational delay
=6msec
Spindle speed= 10000 rpm
Sectors per
track=170sectors
Sector size=512 bytes
What is the average time to
read one sector ?
Disk as Bottleneck
Processes are often Disk-Bound, i.e., the network
and the CPU often have to wait inordinate lengths of
time for the disk to transmit data.
The exponential growth in the performance and
capacity of semiconductor devices and memories,
faster microprocessors with larger and larger
primary memories are continually becoming
available.
To match this growth, it is natural to expect that
secondary storage technology must also take steps to
keep up with processor technology in performance
and reliability.
Assignment 2

Write two short essays(2-3 pages for each essays) on :


Optical disks.
Flash memories.
(Physical description, how to write and read from and to
these media, characteristics, advantages and
disadvantages) all these points have to be included in the
essays.
References also have to presented.
Exercise
Disk characteristics:
 Average seek time = 8 msec.
 Average rotational latency = 3 msec
 Maximum rotational latency = 6 msec.
 Spindle speed = 10,000 rpm
 Sectors per track = 170
 Sector size = 512 bytes
Q) What is the average time to read one
sector?

49
Sequential Reading
 Given the following disk:
 Avg. Seek time, s = 16 ms
 Avg. Rot. Latency, r = 8.3 ms
 Block ( one sector) transfer time, btt = 8.4 ms
a) Calculate the time to read 10 sequential blocks, on
the same track.
b) Calculate the time to read 10 sequential cylinders,
if there are 200 cylinders, and 20 surfaces.

50
Random Reading

Given the same disk,


a) Calculate the time to read 100 blocks randomly
b) Calculate the time to read 100 blocks sequentially.

51
Fast Sequential Reading-FSR
FSR assumes that blocks are arranged so that
there is no rotational delay in transferring
from one track to another within the same
cylinder. This is possible if consecutive track
beginnings are staggered (like running races
on circular race tracks)
assumes that the consecutive blocks are
arranged so that when the next block is on an
adjacent cylinder, there is no rotational delay
after the arm is moved to new cylinder
So, in FSR assume no rotational delay after
finding the first block.
52
Assuming Fast Seq. Reading
 Formulation of Reading b blocks:
i. Sequentially:
s + r + b * btt

 b * btt
s+ r is insignificant for large files, where b is very large: thus

ii. Randomly:
b * (s + r + btt)

53
Exercise
 Given a file of 30000 records, 1600 bytes each,
and block size 2400 bytes, how does record
placement affect sequential reading time, in the
following cases? Discuss.
i) Empty space in blocks-internal fragmentation.
ii) Records overlap block boundaries.

54
Exercise

 Specifications of a disk drive:


 Min seek time, track-to-track = 6ms.
 Average seek time = 18ms
 Rotational delay = 8.3ms
 Transfer time or byte transfer rate=16.7 ms/track or 1229 bytes/ms
 Bytes per sector = 512
 Sectors per track = 40
 Tracks per cylinder = 12 (number of surfaces)
 Tracks per surface = 1331
 Non Interleaving
 Cluster size= 8 sectors
 Smallest extent size = 5 clusters
Q) How long will it take to read a 2048KB file that is
divided into 8000 records, each record 256 bytes?
i) Access the file sequentially, ie. In physical order.
ii) Access the file randomly, in some logical record order.

55
Questions

You might also like