210 likes | 443 Views
Disk Storage : Organization. Disk Storage : Organization. Purpose of the Chapter Disk Storage Organization tracks, sectors and clusters sides and heads cylinders disk controllers File Systems Boot Record FAT (File Allocation Table) Directory and Directory Entry Files
E N D
Disk Storage : Organization • Purpose of the Chapter • Disk Storage Organization • tracks, sectors and clusters • sides and heads • cylinders • disk controllers • File Systems • Boot Record • FAT (File Allocation Table) • Directory and Directory Entry • Files • Open les and le pointers
Sides, Tracks and Sectors • Hard Disk or diskette has a number of sides, each of which is a magnetic surface to store binary information. • Each side is divided to a number of concentric tracks where binary information is actually stored. • Each track is divided to a number of sectors, each of which can store 512 bytes.
Read-Write Head • Each side has a read-write head to read/write data from/to a particular sector. • Disk access latency consists of • seek time: the time for the read-write head to move to the right track • wait time: the time to wait for the right sector to rotate to the position under the read-write head. • Data Transfer Rate - determined by the rate of rotation of the disk.
Cylinder • A set of all the tracks with the same number from all the sides of the disk. • Identifying Sectors of the Disk • Physical Sector: • cylinder #, head/side #, sector * • Sector number starts with 0.
Cluster • a group of sectors as a unit of storage space • The size can be 1, 2, 4, or 8 sectors. • Disk Controller • The hardware device between the disk drive and the processor to handle the communication between them. = Accepts commands from the processor (read/write particular sector) • issues commands to the disk drive to move the accesses arm
Disk Organization and File Systems • Disk Organization • Each raw hard disk can be divided into a number of partitions. • Each partition • is a separate file system • occupies certain number of sectors in the hard disk
File System • A self-contained system with the internal organization to enable • locate a particular file • write and read a file • create and delete a file • The disk sectors of the partition has to be formatted to • set up the initial organization of the le system • skip faulty sectors
Organization of a File System • System Area • Boot Record • Free Storage Management Record (e.g. FAT) • Top Directory • Data Area • System Files • User Files • Example: 3.5" 1.44 MB diskette • Boot Record: Sector 0 • FAT (File Allocation Table): Sectors 1-18 • Directory: Sectors 19-32 • Data Areas: Sec 33-
Boot Record • a bootstrap routine to load the operating system • from 3EH t0 1FFH • data record about disk and file system • jmp instruction at 00H to jump to 3EH • Directory and Directory Entry • Directory is a table of directory entries, one for each le • A directory entry (32 bytes) contains the information about the file it represents: • Filename • Filename Extension • File Attribute (type of the le) • time and day of last update (or creation) • Starting cluster of the le • Size of the file
Tree Structure of File System • A subdirectory is a special file whose contents are a directory. • Tree Structure of file system • Top node is the root directory. • Leave nodes are data les. • Intermediate nodes are subdirectories stored as
File Allocation Table (FAT) • FAT is a structure used to • manage free clusters on the hard disk • link all the clusters allocated to each data le (including subdirectories) • Contains one entry for each cluster on the hard disk. • 0: free sector • n: the cluster number of the next cluster of the file (starting from 2) • -1: last sector of the le • Each FAT entry contains the cluster number of the next cluster of the file. • First Byte of the FAT • 3.5" 1.44MB Diskette: F0H • Hard disk: F8H
Example • First Byte of the FAT • 3.5" 1.44MB Diskette: F0H • Hard disk: F8H • Second Entry • 3.5" 1.44MB Diskette: FFFFH • Hard disk: FFFFFFH • Entry Size • 3.5" 1.44MB Diskette: 12 bits (1.5 bytes) • Hard disk: 16 bits (two bytes)
FAT entry code and their meaning Why FAT32 ? What is wrong with FAT12?
FAT 12 example For every cluster there is an entry in FAT Here cluster 2 , 3 and 6 are allocated to a file Cluster 2 is the first allocated cluster and 6 is the last with FFF. Cluster 4,8 and 9 are free never used Cluster 5 is free but is has been used before Media type Bit stuff
Effect of Cluster size on performance • Small cluster : efficient use of space, so small files get small cluster, thus no waste of space. But it is Causing fragmentation resulting in slow access time. • Large cluster wasteful for small files but causes less fragmentation. • Cluster sizes go from ½ Kbytes to 32Kbytes
Load named file into debug • Create a single color bmp file in paint call it red.bmp • Debug red.bmp • Examine the bytes representing color