DOC PREVIEW
UMD CMSC 412 - Operating Systems

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 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 20 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 20 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 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

111.1Operating System ConceptsCSMC 412Operating SystemsProf. Ashok K Agrawala© 2004 Ashok AgrawalaSet 1111.2Operating System ConceptsFile-System Interface File Concept Access Methods Directory Structure File System Mounting File Sharing Protection211.3Operating System ConceptsFile Concept Contiguous logical address space Types: ) Data numeric character binary) Program11.4Operating System ConceptsFile 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) Program311.5Operating System ConceptsFile Attributes Name – only information kept in human-readable form 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 disk11.6Operating System ConceptsFile Operations Create Write Read file seek – 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 disk411.7Operating System ConceptsOpen 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 information11.8Operating System ConceptsOpen 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 do511.9Operating System ConceptsFile 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();11.10Operating System ConceptsFile 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();}}}611.11Operating System ConceptsFile Types – Name, Extension11.12Operating System ConceptsAccess Methods Sequential Accessread nextwrite next resetno read after last write(rewrite) Direct Accessread nwrite nposition to nread nextwrite next rewrite nn = relative block number711.13Operating System ConceptsSequential-access File11.14Operating System ConceptsSimulation of Sequential Access on a Direct-access File811.15Operating System ConceptsExample of Index and Relative Files11.16Operating System ConceptsDirectory 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 tapes911.17Operating System ConceptsA Typical File-system Organization11.18Operating System ConceptsInformation in a Device Directory Name  Type Address  Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID Protection information (discuss later)1011.19Operating System ConceptsOperations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system11.20Operating System ConceptsOrganize 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 programs, all games, …)1111.21Operating System ConceptsSingle-Level Directory A single directory for all usersNaming problemGrouping problem11.22Operating System ConceptsTwo-Level Directory Separate directory for each user•Path name•Can have the same file name for different user•Efficient searching•No grouping capability1211.23Operating System ConceptsTree-Structured Directories11.24Operating System ConceptsTree-Structured Directories (Cont) Efficient searching Grouping Capability Current directory (working directory)) cd /spell/mail/prog) type list1311.25Operating System ConceptsTree-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 countDeleting “mail” ⇒ deleting the entire subtree rooted by “mail”11.26Operating System ConceptsAcyclic-Graph Directories Have shared subdirectories and files1411.27Operating System ConceptsAcyclic-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 solution11.28Operating System ConceptsGeneral Graph Directory1511.29Operating System ConceptsGeneral Graph Directory (Cont.) How do we guarantee no cycles?) Allow only links to


View Full Document

UMD CMSC 412 - Operating Systems

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
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 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 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?