Uploaded by Amr Khaled

Lecture2 Physical File Organization

advertisement
Lecture 2
Physical File Organization
(The Organization of Hard Disk)
By
Dr. M. AbdelFattah
1
Contents of Lecture:
• Secondary Storage Devices
• The Organization of Disks
[Platters, Read/Write heads, Arm assembly, Spindle, Arms]
• Estimating Capacities and Space Needs
• Organizing Tracks by sectors
• Organizing Tracks by Blocks
—Sub-blocks
• Non-data overhead
• The Cost of a Disk Access
• Quiz(2)
Secondary Storage Devices
• Since secondary storage is different from
main memory we have to understand how it
works in order to do good file design.
• Two major types of secondary storage:
1. Direct Access Storage Devices (DASD)
2. Serial Access Storage Devices (SASD)
Secondary Storage Devices
1. Direct Access Storage Devices (DASD):
Magnetic Disks:
Hard Disk.
Floppy Disk.
Optical Disks:
CD-ROM (Compact Disk – Read Only Memory).
CD-R (Compact Disk – Recordable).
CD-RW (Compact Disk – ReWritable).
DVD (Digital Video Disk).
2. Serial Access Storage Devices (SASD):
Magnetic Tape
The Organization of Disks:
• We can use disks or Hdd to refer to the hard
disks.
• Next figure show the component inside and
outside the disks.
The Organization of Disks:
• The important components in disks are:
1.
2.
3.
4.
5.
Platters
Read/Write heads
Arm assembly
Spindle
Arms
1.
Platter:
• Platter is the circular disk on which magnetic
data is stored in a hard disk drive.
• Platter can store information on both sides
(surface) of one or more platters.
• All surfaces have the same components at the
same position.
• The platters inside a hard disk are structured to
facilitate to storage and retrieval of data.
1.
Platter:
Each platter is divided into concentric rings called
Tracks.
There are thousands of tracks on each platter.
They look like the rings.
The information is stored in successive tracks on the
surface of the disk.
Track Capacity = number of sectors per track *
bytes per sector
1.
Platter:
Each track is divided into a number of Sectors.
A sector is the smallest addressable portion of a disk.
As a rule; sector holds 512 byte of data.
1.
Platter:
Example:
• If a platter has 1000 tracks, each track contains
33 sectors. Calculate track capacity.
Track Capacity = number of sectors per track * bytes per sector
= 33 * 512 = 16896 byte
1.
Platter:
• Another view of sector organization is the
one maintained by the O.S.’s file manager.
• It views the file as a series of Clusters of
sectors.
A cluster is fixed numbers of contiguous sectors.
• Example:
—If sectors size = 512 byte and cluster size = 3 sectors
The cluster size = 3 * 512 =1536 byte
1.
Platter:
1.
Platter:
Another view of Cylinder.
• Cylinder is a set or number of tracks that are
directly above /below each other.
—All the information on a single cylinder can be
accessed without moving the arm that holds the
read/write heads.
Cylinder Rules:
Number of cylinder = the number of tracks in a surface.
Cylinder Capacity = number of tracks per cylinder * track capacity
1.
Platter:
So, platter has four components:
Sector
Cluster
Track
Cylinder
2.
Read/Write heads:
• Read/write heads are the small part of the disk,
that move above the disk platter.
• Heads only fly above the platter surface
with clearance of as little as 3 nanometers.
• A read-write head moves to the track that
contains the data to be transferred.
• Each surface has its own read/write head.
3.
Arm assembly:
• Arm assembly is an internal set of hard disk
component containing arms which contain the
read/write head.
• The role of the arm assembly is to read and
write information from a set of platters that
are coated with a thin magnetic material.
• When arm assembly stops working the drive is
failure.
3.
Arm assembly:
• When a read statement calls for a particular
byte from a disk file.
• The computer’s operating system finds the
correct platter, track and sector, reads the
entire sector into a special area in memory
called a buffer.
• And then finds the requested byte within that
buffer.
4.
Spindle:
• Spindle holds the platters in a fixed position
with enough space for the read/write arms
to get the data on the disks.
• Also, spindle used to rotate the platters.
• Spindle rotation moves the sector under the
read-write head for reading or writing.
5.
Arms:
• Arms are used to carry, Gide and move the
read/write head.
• Moving this arm is called seeking.
• The arm movement is usually the slowest part
of reading information from a disk.
Estimating Capacities and Space Needs
Sector Capacity ≡ bytes per sector = 512 byte
Cluster Capacity = number of sectors per cluster * bytes per sector
Track Capacity = number of sectors per track * bytes per sector
Cylinder Capacity = number of tracks per cylinder * track capacity
Drive Capacity = number of cylinders * cylinder capacity
Problem to solve:
Solve the following problem:
File information:
—Fixed length records
—Number of records = 90000 records
—Record size = 256 byte
Disk drive information:
—Bytes per sector = 512 byte
—Sectors per track = 60 sectors
—Cylinder height = 14 tracks
—Tracks per surface = 5000 tracks
—Number of sectors per cluster = 4 sectors
Find the following:
1. Number of platters per disk
Number of platters per disk = Cylinder height / 2
= 14 / 2
= 7 platters
2. Number of sides per disk
Number of sides per disk = Cylinder height = 14 sides
Or
Number of sides per disk = number of platters * 2
=7*2
= 14 sides
Find the following:
3. Track size
Track size = number of sectors per track * bytes per sector
= 60 * 512 = 30720 byte
4. Number of cylinders
Number of cylinders = Tracks per surface = 5000 cylinders
5. Cylinder size
Cylinder size = number of tracks per cylinder * track capacity
= Cylinder height * track capacity
= 14 *30720 = 430080 byte
6. Number of sectors per cylinder
Number of sectors per cylinder = Cylinder size / sector size
= 430080 / 512
= 840 sectors per cylinder
Find the following:
7. File size
File size = Number of records * Record size
= 90000 * 256 = 23040000 byte
8. Number of records per sector
Number of records per sector = sector size / record size
= 512 / 256 = 2 records per sector
9. Number of records per track
Number of records per track = track size / record size
= 30720 / 256 = 120 records per track
10.Number of records per cylinder
Number of records per cylinder = cylinder size / record size
= 430080 / 256 = 1680 records per cylinder
Find the following:
11.Number of sectors to save file
Number of sectors per file = file size / sector size
= 23040000 / 512 = 45000 sectors to save file
12.Number of tracks to save file
Number of tracks per file = file size / tracks size
= 23040000 / 30720 = 750 tracks to save file
13.Number of cylinders to save file
Number of cylinders per file = file size / cylinders size
= 23040000 / 430080 = 53.57 cylinders to save file
14.Total disk size
Drive Capacity = number of cylinders * cylinder capacity
= 5000 *430080 = 2150400000 byte
Organizing Tracks by sectors:
• Organizing Tracks by sectors is used by OS.
• Slow access or fragmentation when handling
file of records.
—Fragmentation is loss of space within a sector. This
Due to records not fitting exactly in a sector.
—E.g. Sector size is 512 and record size is 300 bytes.
• Some OS allow the system administrator to use
clusters.
Organizing Tracks by Blocks:
• Organizing Tracks by blocks used by DBMS.
• Disk tracks may be divided into user-defined Block
(page) rather than sectors.
• Block is usually organized to contain an integral
number of logical records.
• Blocking Factor = number of records stored in each
block in a file
• No internal fragmentation, no record spanning two
blocks
• In block-addressing scheme each block of data is
accompanied by one or more sub-blocks containing
extra information about the block.
Sub-blocks:
• A block typically contains sub-blocks:
—Count sub-block: the number of bytes in a block
—Key sub-block (optional): contains the key for the
last record in the data sub-block (disk controller can
search for key without loading it in main memory)
—Data sub-block: contains the Data records
Non-data overhead:
Amount of space used for extra stuff other than
data
• Sector-Organized Disks:
—At the beginning of each sector some info is stored,
such as sector address, track address, condition (if
sector is defective);
—There is some gap between sectors
• Block-Organized Disks:
—Sub-blocks and inter-block gaps is part of the extra
stuff; more non-data overhead than with sectoraddressing.
Exercise
• Consider a block-addressable disk with the
following characteristics:
—Size of track 20,000 bytes.
—Nondata overhead per block = 300 bytes.
—Record size = 100 byte.
• Q) How many records can be stored per
track if blocking factor is
a) 10
b) 60
32
The Cost of a Disk Access:
The time to access a sector in a track on a surface
is divided into 3 components:
• Seek Time:
—Time to move the read/write arm to the correct
cylinder (sector).
• Rotational delay (or latency):
—Time it takes for the disk to rotate so 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.
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
Seek Time
Rotational delay (or
latency)
Transfer time
Action
Time to move the read/write arm to
the correct cylinder
Time it takes for the disk to rotate so
that the desired sector is under the
read/write head
Once the read/write head is
positioned over the data, this is the
time it takes for transferring data
36
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)
37
Latency (rotational delay)
• 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 5000rpm,
which is one revolution per 12 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 – 8 ms average
38
Transfer Time
• 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 bytes transferred
Transfer time = --------------------------------- x rotation time
number of bytes on a track
OR
Transfer time=Revolution time/#sector per tracks
• e.g. if there are 63 sectors per track, the time to
transfer one sector would be 1/63 of a revolution.
39
Example (1)
Example (2-1)
Example(2-2)
Quiz(2)
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) Average latency
b) Disk capacity
c) Time to read the entire disk, one cylinder at a time
45
Download