1 / 40

Operating Systems

Operating Systems. Certificate Program in Software Development CSE-TC and CSIM, AIT September -- November, 2003. Objectives describe the user interface to the file system (files, directories, access). 10. File System Interface (Ch. 10 S&G). Contents. 1. The File Concept 2. Access Methods

dara
Download Presentation

Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems Certificate Program in Software DevelopmentCSE-TC and CSIM, AITSeptember -- November, 2003 • Objectives • describe the user interface to the file system (files, directories, access) 10. File System Interface(Ch. 10 S&G)

  2. Contents 1. The File Concept 2. Access Methods 3. Directory Structure 4. Protection 5. Consistency Semantics

  3. 1. The File Concept • The file system provides a uniform logical view of physical storage. • Smallest logical storage unit is the file • usually mapped to storage on a nonvolatile physical device

  4. 1.1. File Attributes • Name • Type • Location • Size • Protection • access controls for who can read, write, execute the file • Time(s)

  5. 1.2. File Operations • View a file as an abstract data type • data as bits/bytes/lines/records • operations • Six basic operations: • create, write, read, seek in a file, delete, truncate continued

  6. Requires read and write pointers, or a current-file-position pointer. • Other possible operations: • append, copy, rename • get/set file attributes • etc.

  7. 1.3. Opening a File • open() finds the file and stores a pointer to it in an open file table (OFT). • I/O operations use the pointer rather than the file name so there is no need to search for the file each time.

  8. Multi-user Variation • Several users may have the same file open at the same time. • Use two levels of internal tables: • an OFT per process storing details on the open files of the process • e.g. file pointers, access rights • a system-wide OFT storing process-independent details on the files • location on disk, size, open count, lock(s)

  9. Two-level File Tables VUW CS 305 OFT process P1 OFT system OFT process P2

  10. 1.4. File Types • Useful so the OS can automatically modify its processing behaviour • e.g. differentiate between source code (open with an editor) and object code (execute) • know that files are ‘related’e.g. example.c and example.o continued

  11. Approaches: • file name extensions (e.g. Windows) • creator attributes (e.g. Mac) • magic numbers (e.g. UNIX)

  12. 1.5. File Structures • Most modern OSes support a minimal number of file structures directly • e.g. UNIX sees every file as a sequence of 8-bit bytes • Benefits: • applications have more flexibility • simplifies the OS

  13. Internal File Structures • Packing is required to convert between logical records and physical blocks • internal fragmentation will occur Logical records Physical blocks

  14. 2. Access Methods • 2.1. Sequential Access Fig. 10.3, p.347 currentposition end beginning rewind read or write

  15. 2.2. Direct Access • A file is made up of fixed length logical records (a disk model). • Can move quickly to any record location by supplying a relative record number • relative to the current record position • e.g. seek(20); // move to rec. 20seek(-1); // move to rec. 19read();

  16. 2.3. Indexed Access Fig. 10.5, p.349 • Make an index file for the file, which contains pointers to various records • improves search time indexfile Adams Arthur Smith, John 007 23 Asher :: Smith direct access file

  17. 2.4. Memory Mapping • Map sections of a file into virtual memory. • Reads and writes to the mapped region act as reads and writes to the file. • Useful way of sharing a file • but requires a mutual exclusion mechanism continued

  18. Memory Mapping Diagram file region region Process Bvirtual memory Process Avirtual memory physical memory

  19. 3. Directory Structure • Partitions (mini-disks, volumes) • provide separate logical spaces on one disk • group several disks into a single logical space • Device directory • holds file information (e.g. name, location, size, type) for all files in that partition

  20. Typical Directory Operations • Search • Create a file • Delete a file • List a directory • Remove a file • Traverse all the files • e.g. for making backups

  21. Types of Directory Structure • 3.1. Single-level Directory • 3.2. Two-level Directory • 3.3. Tree-structured Directory • 3.4. Acyclic Graph Directory • 3.5. General Graph Directory

  22. 3.1. Single-level Directory Fig. 10.7, p.351 • Easy to support and understand. • Problems start when there are large numbers of files and/or users. log foo recs1 test data mail recs2

  23. 3.2. Two-level Directory Fig. 10.8, p.352 Master File Directory (MFD) user1 user2 user3 User FileDirectory (UFD) log foo recs1 test data mail recs2 continued

  24. Some Issues • How isolated are users? • How is a path defined? • e.g. /user1/foo • How do users access system files? • copying • (extendible) search paths

  25. 3.3. Tree-structured Directory Fig. 10.9, p.354 root dict spell words count list list all w count list rade w7 continued

  26. Treat a subdirectory like another file • use a special bit in the directory entry to distinguish a file (0) from a subdirectory (1) • Absolute vs. relative path names? • e.g. /spell/words/rade ../spell/words/rade • How is a non-empty subdirectory deleted?

  27. 3.4. Acyclic Graph Directory Fig. 10.10, p.357 root dict spell words count list list all w count list rade w7 continued

  28. A natural generalisation of a tree-structured directory scheme • allows files/subdirectories to be shared • How are cycles avoided? • A file/subdirectory may have multiple absolute path names • complicates traversal continued

  29. How are shared files/subdirectories deleted? • leave ‘dangling pointers’ (cheap) • use an access list (expensive) • use a reference count

  30. Sharing in UNIX • Symbolic links • a pointer to another file/subdirectory • easily identified by a bit set in the file entry • deletion leaves links ‘dangling’ • Hard links • keep a reference count for hard links to a file • cannot link to a subdirectory • avoids cyclic graphs

  31. 3.5. General Graph Directory Fig. 10.10, p.357 root avi jim book mail text mail count book avi count continued

  32. Traversal could go into an infinite loop • use a bounded search • A subdirectory that refers to itself will never have a reference count of 0 • not possible to delete it • Garbage collection is required to reclaim inaccessible files/subdirectories • very expensive

  33. 4. Protection • Protection mechanisms control/limit file and directory access operations, such as: • reading, writing, execution,appending, deletion, listing • Protection levels and types depend on the system • PC --> corporate installation

  34. 4.1. Access Lists & Fields • Access List • specify access rights for every user of every file • tedious; leads to very large lists • Fields (Groups) • owner/group/world • each field in UNIX has 3 bits for read, write, and execute permissions

  35. UNIX Example Fig. 10.12, p.364 • bazooka<ad>47: ls -ltotal 62drwxr-xr-x 2 ad 512 Nov 4 1998 Figures/-rw-r--r-- 1 ad 14109 Nov 12 1998 Listings-rw-r--r-- 1 ad 1878 Nov 4 1998 abstract.tex-rw-r--r-- 1 ad 782 Nov 4 1998 cover-notedrwxr-xr-x 2 ad 512 Feb 16 08:59 old_code/-rw-r--r-- 1 ad 24450 Nov 4 1998 progHTTP.txtdrwxr-xr-x 2 ad 512 Nov 12 1998 revisted/-rwxr-xr-x 1 ad 11676 Feb 16 08:52 sock_brow*-rw-r--r-- 1 ad 4150 Dec 22 17:07 sock_brow.c-rw-r--r-- 1 ad 887 Nov 4 1998 web-tech-addr

  36. 4.2. Passwords • A password per file • too hard to remember • A password per subdirectory • too course-grained

  37. 5. Consistency Semantics • Consistency semantics is how an OS deals with modifications to a shared file by multiple users who are accessing the file at the same time.

  38. Consistency Sems for UNIX • A write is immediately visible to every shared users. • Processes may share the current position pointer of the file. • Users see a shared file as representing a single physical entity.

  39. Consistency Sems for Andrew FS • A distributed file system from CMU. • A write is notimmediately visible. • A change becomes visible to subsequent opens after the file has been closed. • Users see a shared file as representing several temporary (possibly different) images of the single physical entity.

  40. Immutable Shared Files • A type of file which cannot be modified if it is declared as shareable by its creator. • Greatly simplifies sharing in a distributed file system.

More Related