3 April 2002 Operating Systems Memory Management wrap up File Management Read Nutt Ch 13 ------------------- File Access sequential: tapes - write as append. read 1,2,3,... can rewind to beginning, read current position sometimes can write to middle of tape - rarely e.g., compact disk music files, tapes direct (random) access -- any address in file readable/writable position declared or current e.g., UNIX files indexed sequential access -- master index -> secondary index -> data block each file sorted on key binary search on master index to get to correct secondary index bin search secondary linear search block B-tree height = 2 minimize num disk accesses to find something tradeoff user space (flexibility) or kernel space (speed) DB experts dont' like kernel-implemented indexing e.g., data base entries Directories maps names to file logical structure - dir may actually be a file dir ops: search, create, delete, list, traverse single level - one masterneed unique names simple, limited, but meaningful for embeded sys? original dos 1.0 search entire dir for file - expensive two level - isolate users - each user is flat user id/filename is unique can easily isolate users from one another with protection if want sharing, need extensions hierarchical - generalize two level users aassigned subtrees MacOS, win, dos 2.0+ relative or absolute path names acyclic - generalize hierarchical shared files - not copying (as would be required in tree) soft link (symbolic link) unix, mac:alias, win:shortcut can distinguish orig from copy can cross file system boundaries can be left dangling hard link - duplicates directory entry does not duplicate file not allowed to adirectories soft link slower, more lookup what if delete original, then recreate it? sym links ref "new" orig hard links to not sym links can lead to cycles - unix quits after 8 symlinks in translating path -------- Device Space Management Efficiency - good use of available space - wrork with blocks - internal/external fragmentation - contiguout/indexed - redundancy increases reliability - recover from crashes Performance - depends on access patterns - cache data/ directory info device buffers entire track Choice of allocation ? sector = minimum - reasonable groups of sectors - increase throughput - decrease utilitzation Allocation strategies Contiguous - dir entry: start addr length - random access simple - allocation hard - external frag - compaction takes time - must estimate size - if run out of space: error or copy to bigger space - overestimage leads to internal frag - allow an extent - efficient for small files if lots of files smaller than allocation units scattered - like paging. allocate in smallest addressable unit - allow file to be scattered on HD - need efficient mechanism to find address - 2 basic options linked/indexed Linked linked list of address blocks sequential access is good pointers require disk space - use bigger blocks reliability - lost pointer corrupt pionter solutions: doubly linked/redundant info - more space FAT: file allocation table DOS OS2 modification to address faseter access section at beginning of partition for table table has one entry per block indexed by block directory entry: index of first block table entry: next block num, EOF, 0 (unused) still hop through FAT entries for random access faster than normal linked because all seeks in same part of disk sequential - may be slow FAT->DATA->FAT->DATA cache FAT lots of disk space