Docsity

Modified Linked Allocation in Operating Systems - Lecture Slides | CMSC 412, Study notes of Operating Systems

Partial preview of the text

Download Modified Linked Allocation in Operating Systems - Lecture Slides | CMSC 412 and more Study notes Operating Systems in PDF only on Docsity!

Announcements

z

Reading Chapter 12

Modified Linked Allocation (FAT)

z

Section of disk contains a table^ – called the file allocate table (FAT)^ – used in MS-DOS

z

Directory entry contains the block number of the firstblock in the file

z

Table entry contains the number of the next block inthe file

z

Last block has a end-of-file value as a table entry

directory entry last entry(for a file)has EOF ptr FAT th i block corresponds to the i th FAT entry

Free Space Management

z

How do we find a disk block to allocate?

z

Bit Vectors

  • array of bits (one per block) that indicates if a block is free – compact so can keep in memory
    • 1.3 GB disk, 4K blocks -> 78K per disk
      • easy to find long runs of free blocks z

Linked lists

  • each disk block contains the pointer to the next free block – pointer to first free block is keep in a special location on disk z

Run length encoding (called counting in book)

  • pointer to first free block is keep in a special location on disk – each free block also includes a count of the number of consecutive blocks that are free

Implementing Directories

z

Linear List

  • array of names for files – must search entire list to find or allocate a filename – sorting can improve search performance, but adds complexity z

Hash table

  • use hash function to find filenames in directory – needs a good hash function – need to resolve collisions – must keep table small and expand on demand since many directories are mostly empty

Unix Directories

z

Space for directories are allocated in units called chunks

  • Size of a chunk is chosen so that each allocation can be transferred to disk in a single operation - Chunks are broken into variable-length directory entries to allow filenames of arbitrary length - No directory entry can span more than one chunk – Directory entry contains - pointer to inode (file data-structure) • size of entry • length of filename contained in entry (up to 255) • remainder of entry is variable length - contains file name

inodes

z

File index node

z

Contains:

  • Pointers to blocks in a file (direct, single indirect, double indirect, triple indirect) - Type and access mode – File’s owner – Number of references to file – Size of file – Number of physical blocks

Root inode = usr bin vi

File Lookup (/usr/bin/vi)

Directory Entry Inode Directory Entry Inode Indirect Index Directory Entry Data Block

Using UNIX filesystem data structures

z

Example: find /usr/bin/vi

  • from Leffler, McKusick, Karels and Quarterman – Search root directory of filesystem to find /usr

    root directory inode is, by convention, stored in inode # - inode shows where data blocks are for root directory - these blocks (not the inode itself) must be retrieved and searched for entry user - we discover that the directory user’s inode is inode # - Search user for bin - access blocks pointed to by inode #4 and search contents ofblocks for entry that gives us bin’s inode - we discover that bin’s inode is inode # - Search bin for vi - access blocks pointed to by inode #7 and search contents ofblock for an entry that gives us vi’s inode - we discover that vi’s inode is inode # - Access inode #7 - this is vi’s inode

Access Times

z Seek: Move disk arm over appropriate track

Seek times vary depending on locality - seek times are order ofmilliseconds z Rotational delay: Wait time until desired information is underdisk arm - A disk that rotates at 7200 RPM will take 8.3 ms to complete a fullrotation z Transfer time: time taken to transfer a block of bits (usually asector) - Depends on recording density of track, rotation speed, block size - Achieved transfer rate for many blocks can also be influenced byother system bottlenecks (software, hardware) - Rates range from 2 to 8 MB per second