================ Start Lecture 13 ================ HOMEWORK 10.1, 10.7 File names and types Should extenstions determine the file type? Works well when it works Works poorly when it doesn't Good for hints OS needs to know if executable HOMEWORK 10.5 Structured files Should it be part of the supervisor-mode OS Unix says no MVS says yes Accessing file daya Sequential Access (common for tape) Direct Access Indexed files (databases) HOMEWORK 10.9 Directory Mapping of names (subdirectories and files) to locations Written as side effects of file ops, e.g. create delete Subdirectories give a tree. Normally permit a DAG NON-unique names! Hard vs symbolic links Cycles can be a problem Can prevent by not forbidding links to directories In unix hard links can't be to directories but symlinks can HOMEWORK 10.6 File protection (a.k.a permissions) Simplest is no protection Also easy is distinguish operations (r/w/e append delete) and treat all users the same (no "users") Also easy is just owner can access Unix has owner, group, other Most general is a protection (a.k.a. permission) matrix Row for each user Column for each file Entry gives access for that file to that user Read a row and get capability list for the user Read a column and get access list for a file ---------------- Chapter 11 File-system Implementation ---------------- Storing a file Obvious method is CONTIGUOUS ALLOCATION No seeks to read or write the next block External fragmentation Holes Sound familiar ? The analogue of paging is called INDEXED ALLOCATION Problem is files often grow and shrink (segments grow/shrink much less often) How grow the index (page table) CP/M disk block numbers (PTEs) stored in directory entry If need more blocks than fit in a dir entry, make a second dir entry Unix method is direct / indirect / double-indirect blocks Store direct block numbers, block number of indirect block and block number of double indirect block in the "inode" (index-node, information-node). Dir entry points to the inode. Hard links point to the same inode LINKED ALLOCATION Dir entry points to first block. Each points to next MSDOS similar FAT (file alloc table) contains one entry for each disk block. Dir entry gives first block number. Corresponding FAT entry contains next block number Last FAT entry for this file contains EOF HOMEWORK 11.1 Log Structured Filesystems (Not covered; not in book) Increased caching increases the write percentage. Writes are small so inefficient Gather up writes and write to end of "log" i.e. don't rewrite block Eventually need to clean (garbage collect) Free-space management Bit vector Linked list of free blocks HOMEWORK 11.2 Directory implementation Natural is linear list of entries Hashed is faster for search Recovery (skip) File system check Backups ---------------- Chapter 12 Secondary Storage Structure ---------------- Disk (Arm) Scheduling FCFS -- Simple but large seeks Pick -- FCFS but pick up any on the way SSTF (Shortest Seek Time First) Greedy algorithm Can starve Blocks at edge less well serviced HOMEWORK 12.7 SCAN (LOOK, Elevator) Jukebox algorithm Favors middle Book says SCAN always goes to edge, LOOK turns around when no more to do. I use SCAN and LOOK to mean turn around when no more to do. C-SCAN (Circular Scan) Only go in one direction; then go back to beginning Doesn't favor middle N-step SCAN Do not service requests arriving during current scan HOMEWORK 12.1 (is 12.1a true for algs I added?), 12.2, 12.4 Disk Latency Scheduling On a given track (or cylinder) use SCAN (same as C-SCAN) HOMEWORK 12.9