DOC PREVIEW
UMD CMSC 412 - Operating Systems Set 10

This preview shows page 1-2-3-19-20-39-40-41 out of 41 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSMC 412Operating SystemsProf. Ashok K Agrawala© 2006 Ashok AgrawalaSet 10October 2006 1CMSC 412 Set 10File-System Interface• File Concept• Access Methods• Directory Structure• File-System Mounting• File Sharing• ProtectionOctober 2006 2CMSC 412 Set 10Objectives• To explain the function of file systems• To describe the interfaces to file systems• To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures• To explore file-system protectionOctober 2006 3CMSC 412 Set 10File Concept• Contiguous logical address space• Types: – Data• numeric• character• binary– ProgramOctober 2006 4CMSC 412 Set 10File Structure• None - sequence of words, bytes• Simple record structure– Lines – Fixed length– Variable length• Complex Structures– Formatted document– Relocatable load file• Can simulate last two with first method by inserting appropriate control characters• Who decides:– Operating system– ProgramOctober 2006 5CMSC 412 Set 10File Attributes• Name – only information kept in human-readable form• Identifier – unique tag (number) identifies file within file system• Type – needed for systems that support different types• Location – pointer to file location on device• Size – current file size• Protection – controls who can do reading, writing, executing• Time, date, and user identification – data for protection, security, and usage monitoring• Information about files are kept in the directory structure, which is maintained on the diskOctober 2006 6CMSC 412 Set 10File Operations• File is an abstract data type• Create• Write• Read• Reposition within file• Delete• Truncate• Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory• Close (Fi) – move the content of entry Fiin memory to directory structure on diskOctober 2006 7CMSC 412 Set 10Open Files• Several pieces of data are needed to manage open files:– File pointer: pointer to last read/write location, per process that has the file open– File-open count: counter of number of times a file is open – to allow removal of data from open-file table when last processes closes it– Disk location of the file: cache of data access information– Access rights: per-process access mode informationOctober 2006 8CMSC 412 Set 10Open File Locking• Provided by some operating systems and file systems• Mediates access to a file• Mandatory or advisory:– Mandatory – access is denied depending on locks held and requested– Advisory – processes can find status of locks and decide what to doOctober 2006 9CMSC 412 Set 10File Locking Example – Java APIimport java.io.*;import java.nio.channels.*;public class LockingExample { public static final boolean EXCLUSIVE = false;public static final boolean SHARED = true;public static void main(String arsg[]) throws IOException { FileLock sharedLock = null;FileLock exclusiveLock = null;try { RandomAccessFile raf = new RandomAccessFile("file.txt", "rw");// get the channel for the fileFileChannel ch = raf.getChannel();// this locks the first half of the file - exclusiveexclusiveLock = ch.lock(0, raf.length()/2, EXCLUSIVE);/** Now modify the data . . . */// release the lockexclusiveLock.release();October 2006 10CMSC 412 Set 10File Locking Example – Java API (cont)// this locks the second half of the file - sharedsharedLock = ch.lock(raf.length()/2+1, raf.length(), SHARED);/** Now read the data . . . */// release the lockexclusiveLock.release();} catch (java.io.IOException ioe) {System.err.println(ioe);}finally {if (exclusiveLock != null)exclusiveLock.release();if (sharedLock != null)sharedLock.release();}}}October 2006 11CMSC 412 Set 10File Types – Name, ExtensionOctober 2006 12CMSC 412 Set 10Access Methods• Sequential Accessread nextwrite next resetno read after last write(rewrite)• Direct Accessread nwrite nposition to nread nextwrite next rewrite nn = relative block numberOctober 2006 13CMSC 412 Set 10Sequential-access FileOctober 2006 14CMSC 412 Set 10Simulation of Sequential Access on a Direct-access FileOctober 2006 15CMSC 412 Set 10Example of Index and Relative FilesOctober 2006 16CMSC 412 Set 10Directory Structure• A collection of nodes containing information about all filesF 1F 2F 3F 4F nDirectoryFilesBoth the directory structure and the files reside on diskBackups of these two structures are kept on tapesOctober 2006 17CMSC 412 Set 10A Typical File-system OrganizationOctober 2006 18CMSC 412 Set 10Operations Performed on Directory• Search for a file• Create a file• Delete a file• List a directory• Rename a file• Traverse the file systemOctober 2006 19CMSC 412 Set 10Organize the Directory (Logically) to Obtain• Efficiency – locating a file quickly• Naming – convenient to users– Two users can have same name for different files– The same file can have several different names• Grouping – logical grouping of files by properties, (e.g., all Java program s, all gam es, … )October 2006 20CMSC 412 Set 10Single-Level Directory• A single directory for all usersNaming problemGrouping problemOctober 2006 21CMSC 412 Set 10Two-Level Directory• Separate directory for each usern Path namen Can have the same file name for different usern Efficient searchingn No grouping capabilityOctober 2006 22CMSC 412 Set 10Tree-Structured DirectoriesOctober 2006 23CMSC 412 Set 10Tree-Structured Directories (Cont)• Efficient searching• Grouping Capability• Current directory (working directory)– cd /spell/mail/prog– type listOctober 2006 24CMSC 412 Set 10Tree-Structured Directories (Cont)• Absolute or relative path name• Creating a new file is done in current directory• Delete a filerm <file-name>• Creating a new subdirectory is done in current directorymkdir <dir-name>Example: if in current directory /mailmkdir countmailprog copy prt exp countD eleting “m ail”  deleting the entire subtree rooted by “m ail”October 2006 25CMSC 412 Set 10Acyclic-Graph Directories• Have shared subdirectories and filesOctober 2006 26CMSC 412 Set 10Acyclic-Graph Directories (Cont.)• Two different names (aliasing)• If dict deletes list  dangling pointerSolutions:– Backpointers, so we can delete all pointersVariable size records a problem– Backpointers using a daisy chain organization– Entry-hold-count solution• New directory entry type– Link –


View Full Document

UMD CMSC 412 - Operating Systems Set 10

Documents in this Course
Security

Security

65 pages

Deadlocks

Deadlocks

22 pages

Set 2

Set 2

70 pages

Project 2

Project 2

21 pages

Load more
Download Operating Systems Set 10
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Operating Systems Set 10 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 Operating Systems Set 10 2 2 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?