Unformatted text preview:

Recap 1 Stack PRAs Working Set Working Set PRA WSClock PRA Segmentation Pure Segments Segments with Paging File Systems Size Persistence Multiple Access Moran OS Lecture 9 1 Recap 2 File Names File Contents File Types Files without Types what does a out do Moran OS Lecture 9 2 File Attributes Protection Password Creator Owner Read Only Flag Hidden Flag System Flag Archive Flag Text Flag Random Access Flag Temporary Flag Lock Flags Record Length Key Position Key Length Creation Time Access Time Change Time Current Size Max Size Audit Flags Moran OS Lecture 9 3 File Operations 1 Create creat in Unix How we create a new file may be subsumed in open Delete unlink in Unix How we make the name go away may or may not reclaim the storage Open How we map the name to internal OS structures saves having to do this on every access Close How we remove the map of the name to the internal structures may flush buffers to disk Read How we get data from the file into memory Moran OS Lecture 9 4 File Operations 2 Write How we take data from memory and put it in the file usually writes to the current location it may truncate Seek Make the current location different for subsequent file operations Get Attributes fstat in Unix How we check the values of various attributes Set Attributes Rename How we give the file a new name Tanenbaum is wrong about copy delete Moran OS Lecture 9 5 Memory Mapped Files An elegant way of associating an address range in the memory address space with the file normal memory operations work well the address range may be gotten most cleanly as a segment A file copy might be a clean as for int i 0 i len i x y We will use the file itself as the backing store for the pages Moran OS Lecture 9 6 Memory Mapped File Issues How do we handle file i o and memory access to the same file at the same time Usually this has undefined behavior What if the file is bigger than the virtual address space of the process We map only a piece of the file into the address space Won t be an issue with 64 bit address spaces Moran OS Lecture 9 7 Directories 1 A directory contains some number of entries one per file name possibly multiple names for the same file the primary way of structuring the storage of files Depending on the system there may be one or more directories some have one directory per user some have one directory for the whole system modern systems tend to have many directories With many directories directories are typically entries in another directory Moran OS Lecture 9 8 Directories 2 Hierarchical Directories We have a way of finding a path to a directory The path consists of a sequence of directories starting at some root There is a path separator On DOS it is On Unix it is On Multics it was It can really be anything that cannot appear in a legal file or directory name A path is of the form a b c d Possible different roots for network file systems Moran OS Lecture 9 9 Naming Directories and Contents We want to be able to name every directory We want to be able to name the contents of every directory Example foo is a directory bar is a directory in foo baz txt is a file in bar Unix has foo bar baz txt DOS has foo bar baz txt Other systems have used etc The important point is that the separator allows us to distinguish the components Moran OS Lecture 9 10 Absolute vs Relative Paths Processes have a notion of a current directory where the process currently is in the file system File can be named with respect to the current directories Absolute path names allow is to find the file from anywhere Relative paths require that we start at the appropriate current directory Unix has a notion of and to support the idea of relative paths Moran OS Lecture 9 11 Directory Operations 1 Create create an empty directory are there Delete delete an empty directory Opendir as with files this creates the internal structures necessary to access the directory Closedir as with files Moran OS Lecture 9 12 Directory Operations 2 Readdir read the contents of a directory People used to use read for this but that exposes the directory structure and that is thought to be very bad thing Rename as with files Link Given an entry in a directory add a new name for it Unlink Remove an entry in the directory Moran OS Lecture 9 13 Implementing Files Disk Hardware Disks operate on sectors they don t operate on single words Disk blocks the unit seen by the file system are usually multiple sectors Allocating the blocks in a file Contiguous Allocation Linked Allocation File Allocation Table FAT Inodes Moran OS Lecture 9 14 Contiguous Allocation At creation time all of the space for the file is allocated If the file were ever resized it would be necessary to move the whole thing like Multiprogramming with fixed partitions Simple and fast for access Not useful for general purpose systems but it works well for read only and other systems where file size is known at creation time Used by some older mainframe file systems CDs Moran OS Lecture 9 15 Linked Allocation Directory entry contains a link to the first block in the file Each block contains a pointer to the next block Has a number of serious drawbacks Random access is horrendous Blocks have lost some space and are not power of two anymore No real systems do things this way Moran OS Lecture 9 16 File Allocation Table Directory entry points to the first block in the file A table is maintained in memory that for block N contains the next block in the file for the same file This is a linked implementation but the links Are stored separately from the blocks Are kept in memory so random access isn t as bad The table requires one word per disk block 4k blocks 4 byte words means 1M table per 1G disk Requires that disk blocks are fairly large DOS and Windows do it this way Moran OS Lecture 9 17 Inodes Directories point to index nodes Inodes Inodes have several kinds of pointers direct blocks indirect blocks double indirect blocks triple indirect blocks Inodes are kept in memory for open files Many references take one I O Some take two Very few take three Unix did things this way Moran OS Lecture 9 18 Inode Contents File Owner uid File Type regular directory special FIFO File Permissions File Access Times access modify inode modify Number of links to the file Table of contents of the disk blocks File Size Moran OS Lecture 9 19 Inode Pointers 10 direct blocks 1 single indirect 1 double indirect 1 triple indirect With 1K disk blocks 10K in the directs 1k x 10 256K in the single indirect


View Full Document

NYU CSCI-GA 2250 - Lecture Notes

Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?