University of Dublin Hardware Issues Trinity College

Hard Disk

Main Memory Main CD ROM/RW

CPU Storage Hardware DVD ROM/RW

Tapes

[email protected] Primary Storage

Secondary Storage

Storage Hardware 2

Hardware Issues Hardware Issues

Primary Storage is … Secondary Storage is …

• Limited • Extendible •Volatile • Persistent • Expensive • Cheap

However, it is also … However, it is …

• Fast (May be accessed directly from the CPU) • Relatively slow (must be copied to main memory before being accessed by the CPU)

Storage Hardware 3 Storage Hardware 4

Hardware Issues Disk Storage Devices

Why do we use secondary storage? Disk Storage Devices …

• Primary storage (RAM) costs more than disk space • Direct Access Storage • We like to switch our off and on again – As opposed to Tape drives, which are serial devices • Offer high storage capacity and low cost • stored as magnetized areas on magnetic platters But secondary storage is very slow surfaces • Each disk has one or more platters • Retrieving a single character from RAM takes about 150 •A disk pack contains several magnetic platters connected nanoseconds (150 billionths of a second) to a rotating spindle • Retrieving the same character from disk takes about 75 milliseconds (thousandths of a second) • 75 msec is 500,000 times longer than 150 ns.

Storage Hardware 5 Storage Hardware 6

1 Disk Pack with Read/Write H/W Movable vs Fixed-head Disks

Spindle Some disks have fixed-heads Arm Read/Write Head Cylinder of Actuator Tracks (imaginary) • As many read/write heads as there are tracks on the platter • Track is selected electronically and is therefore much faster • Cost of additional read/write heads is the limiting factor to production

Magnetic Disk Disks with an actuator are called moveable-head disks

• Actuator moves the (single) read/write head per platter to the appropriate track

Actuator Rotation Movement

Storage Hardware 7 Storage Hardware 8

Tracks and Sectors Cylinder Sector (arc of a track) Tracks directly above and below one another form a cylinder

All information on a cylinder can be accessed without moving the arm (called seeking) that holds the Track Platter read/write heads • Disks are divided into concentric circular tracks on each platter surface • Track capacities vary typically from 4 to 50 Kbytes • A cylinder consists of a group of tracks • The division of the disk into sectors is hard-coded and may not be • A track consists of a group of sectors changed • A sector consists of a group of bytes • Subtended at fixed angle at the centre of a platter are sectors (figure above) • Not all disks have their tracks divided into sectors

Storage Hardware 9 Storage Hardware 10

Estimating Capacities Estimating Capacities

Track capacity = #sectors per track * bytes per sector Answer – Cylinder capacity = #tracks per cylinder * Track capacity Drive capacity = #cylinders * Cylinder capacity • The file is 20,000 * 256 = 5,120,000 bytes • 5,120,000 / 512 = 10,000 sectors • 10,000 / 40 = 250 tracks Knowing these relationships allows us to compute the • 250 / 11 = 22.72 cylinders amount of disk space a file is likely to require • How many cylinders to store a file with 20,000 fixed length records 1f 22.72 physically contiguous cylinders are not of 256 bytes each on a disk with – available then the file will have to be spread out over – 512 bytes per sector the disk (fragmentation) – 40 sectors per disk – 11 tracks per cylinder

Storage Hardware 11 Storage Hardware 12

2 Blocks Disk I/O

What are Blocks? Input/Output (I/O) from/to a Disk …

•A read-write head moves to the track that contains the to be • A track is divided into blocks or pages transferred (seek) • Block size (generally) fixed for each operating system • Disk rotation moves the block under the read-write head for • Typical block sizes range from 512 bytes to 4096 bytes reading and writing (rotational delay or latency) • Operating System finds the correct block • A disk with hard-coded sectors often has the sectors further – A physical disk block address consists of a surface number, track number (within subdivided onto blocks surface), and block number (within track) • Entire block read/written from/to an area in RAM called a buffer • Time taken to transfer the block (block transfer time) Why are they important? Reading or writing a disk block is time consuming • Whole blocks are transferred between disk and because of the seek times and rotational delay main memory for processing • Double buffering can be used to speed up the transfer of contiguous disk blocks

Storage Hardware 13 Storage Hardware 14

Buffers Example of Double Buffering

When several blocks need to be transferred from disk to Use of two buffers, A and B, for reading from disk main memory (and all the block addresses are known beforehand) several buffers can be reserved in main Disk Block : i i + 1 i + 2 i + 3 i + 4 memory to speed the transfer fill A fill B fill A fill B fill A • CPU processes data in a buffer while another is being read/written IO

Facilitated by independent Input/Output Disk Block : i i + 1 i + 2 i + 3 i + 4 • Can transfer data block to/from main memory independent of and in process process process process process A B A B A parallel to CPU processor Processing • This technique is referred to as double buffering

Time

Storage Hardware 15 Storage Hardware 16

Physical and Logical Files Sector Organisation

A disk drive may contain many physical files There are two basic ways to organise data on a disk – by sector organisation or user-defined block • A program uses these files via the operating system, but knows We will study only sector organisation nothing about where the data is on disk The physical placement of sectors – A program sees only logical files • You cannot read a series of sectors that are all in the same track one right after another! • When a program wants to access a file, the operating system • After reading the data, it takes the machine time to process the provides the hook-up between logical and physical file data before retrieving more • The programmer does not need to know the physical location on •So, if logically adjacent sectors were placed physically adjacent, disk, just the logical name creating retrieval would be slow • Solution : Interleave the sectors

Storage Hardware 17 Storage Hardware 18

3 Sector Organisation - Clusters Review

A cluster is a fixed number of contiguous sectors Compared to RAM disk accesses are slow, but cheap! • All clusters on a disk are the same size Disks facilitate persistent storage of data • To view a file as a series of clusters and still maintain the sectored view, the file manager ties the logical sectors to the physical Disks enable direct access clusters using a file allocation table (FAT) Anatomy of a Disk • Platters, tracks, cylinders, sectors, blocks FAT - Physical components of a Disk • The FAT contains a linked list of all the clusters in a file, ordered • Magnetic disks, actuator, arm, read/write heads, spindle according to the logical order of the sectors in a cluster Estimating Capacities • With each entry in the FAT is an entry giving the physical location of the cluster Disk I/O and Buffering Sector Organisation and Clustering

Storage Hardware 19 Storage Hardware 20

4