Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface
lượt xem 10
download
Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface trình bày về khái niệm tập tin, phương pháp truy cập, cấu trúc thư mục, tập tin hệ thống gắn, file sharing,..Mời bạn đọc cùng tham khảo.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface
- Chapter 10: File-System Interface Operating System Concepts – 8th Edition Operating System Concepts – 8th Edition 10.1 Silberschatz, Galvin and Gagne ©2009
- Chapter 10: File-System Interface s File Concept s Access Methods s Directory Structure s File-System Mounting s File Sharing s Protection Operating System Concepts – 8th Edition 10.2 Silberschatz, Galvin and Gagne ©2009
- Objectives s To explain the function of file systems s To describe the interfaces to file systems s To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures s To explore file-system protection Operating System Concepts – 8th Edition 10.3 Silberschatz, Galvin and Gagne ©2009
- File Concept s Contiguous logical address space s Types: q Data 4 numeric 4 character 4 binary q Program Operating System Concepts – 8th Edition 10.4 Silberschatz, Galvin and Gagne ©2009
- File Structure s None - sequence of words, bytes s Simple record structure q Lines q Fixed length q Variable length s Complex Structures q Formatted document q Relocatable load file s Can simulate last two with first method by inserting appropriate control characters s Who decides: q Operating system q Program Operating System Concepts – 8th Edition 10.5 Silberschatz, Galvin and Gagne ©2009
- File Attributes s Name – only information kept in human-readable form s Identifier – unique tag (number) identifies file within file system s Type – needed for systems that support different types s Location – pointer to file location on device s Size – current file size s Protection – controls who can do reading, writing, executing s Time, date, and user identification – data for protection, security, and usage monitoring s Information about files are kept in the directory structure, which is maintained on the disk Operating System Concepts – 8th Edition 10.6 Silberschatz, Galvin and Gagne ©2009
- File Operations s File is an abstract data type s Create s Write s Read s Reposition within file s Delete s Truncate s Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory s Close (Fi) – move the content of entry Fi in memory to directory structure on disk Operating System Concepts – 8th Edition 10.7 Silberschatz, Galvin and Gagne ©2009
- Open Files s Several pieces of data are needed to manage open files: q File pointer: pointer to last read/write location, per process that has the file open q 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 q Disk location of the file: cache of data access information q Access rights: per-process access mode information Operating System Concepts – 8th Edition 10.8 Silberschatz, Galvin and Gagne ©2009
- Open File Locking s Provided by some operating systems and file systems s Mediates access to a file s Mandatory or advisory: q Mandatory – access is denied depending on locks held and requested q Advisory – processes can find status of locks and decide what to do Operating System Concepts – 8th Edition 10.9 Silberschatz, Galvin and Gagne ©2009
- File Locking Example – Java API import 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 file FileChannel ch = raf.getChannel(); // this locks the first half of the file - exclusive exclusiveLock = ch.lock(0, raf.length()/2, EXCLUSIVE); /** Now modify the data . . . */ // release the lock exclusiveLock.release(); Operating System Concepts – 8th Edition 10.10 Silberschatz, Galvin and Gagne ©2009
- File Locking Example – Java API (Cont.) // this locks the second half of the file - shared sharedLock = ch.lock(raf.length()/2+1, raf.length(), SHARED); /** Now read the data . . . */ // release the lock sharedLock.release(); } catch (java.io.IOException ioe) { System.err.println(ioe); }finally { if (exclusiveLock != null) exclusiveLock.release(); if (sharedLock != null) sharedLock.release(); } } } Operating System Concepts – 8th Edition 10.11 Silberschatz, Galvin and Gagne ©2009
- File Types – Name, Extension Operating System Concepts – 8th Edition 10.12 Silberschatz, Galvin and Gagne ©2009
- Access Methods s Sequential Access read next write next reset no read after last write (rewrite) s Direct Access read n write n position to n read next write next rewrite n n = relative block number Operating System Concepts – 8th Edition 10.13 Silberschatz, Galvin and Gagne ©2009
- Sequential-access File Operating System Concepts – 8th Edition 10.14 Silberschatz, Galvin and Gagne ©2009
- Simulation of Sequential Access on Direct-access File Operating System Concepts – 8th Edition 10.15 Silberschatz, Galvin and Gagne ©2009
- Example of Index and Relative Files Operating System Concepts – 8th Edition 10.16 Silberschatz, Galvin and Gagne ©2009
- Directory Structure s A collection of nodes containing information about all files Directory Files F1 F2 F4 F3 Fn Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes Operating System Concepts – 8th Edition 10.17 Silberschatz, Galvin and Gagne ©2009
- Disk Structure s Disk can be subdivided into partitions s Disks or partitions can be RAID protected against failure s Disk or partition can be used raw – without a file system, or formatted with a file system s Partitions also known as minidisks, slices s Entity containing file system known as a volume s Each volume containing file system also tracks that file system’s info in device directory or volume table of contents s As well as general-purpose file systems there are many special- purpose file systems, frequently all within the same operating system or computer Operating System Concepts – 8th Edition 10.18 Silberschatz, Galvin and Gagne ©2009
- A Typical File-system Organization Operating System Concepts – 8th Edition 10.19 Silberschatz, Galvin and Gagne ©2009
- Operations Performed on Directory s Search for a file s Create a file s Delete a file s List a directory s Rename a file s Traverse the file system Operating System Concepts – 8th Edition 10.20 Silberschatz, Galvin and Gagne ©2009
CÓ THỂ BẠN MUỐN DOWNLOAD
-
Bài giảng Hệ điều hành nâng cao - Chapter 3: Processes
54 p | 137 | 15
-
Bài giảng Hệ điều hành nâng cao - Chapter 5: CPU Scheduling
67 p | 135 | 14
-
Bài giảng Hệ điều hành nâng cao - Chapter 11: File System Implementation
63 p | 187 | 14
-
Bài giảng Hệ điều hành nâng cao - Chapter 19: Real - Time Systems
24 p | 101 | 13
-
Bài giảng Hệ điều hành nâng cao - Chapter 6: Process Synchronization
72 p | 201 | 11
-
Bài giảng Hệ điều hành nâng cao - Chapter 12: Mass - Storage Systems
57 p | 166 | 10
-
Bài giảng Hệ điều hành nâng cao - Chapter 13: I/O Systems
42 p | 157 | 9
-
Bài giảng Hệ điều hành nâng cao - Chapter 2: Operating - System Structures
54 p | 173 | 9
-
Bài giảng Hệ điều hành nâng cao - Chapter 1: Introduction
48 p | 141 | 8
-
Bài giảng Hệ điều hành nâng cao - Chapter 4: Threads
45 p | 135 | 8
-
Bài giảng Hệ điều hành nâng cao - Chapter 21: The Linux System
62 p | 148 | 7
-
Bài giảng Hệ điều hành nâng cao - Chapter 20: Multimedia Systems
33 p | 128 | 6
-
Bài giảng Hệ điều hành nâng cao - Chapter 22: Windows XP
64 p | 92 | 6
-
Bài giảng Hệ điều hành nâng cao - Chapter 14: Protection
29 p | 77 | 5
-
Bài giảng Hệ điều hành nâng cao - Chapter 17: Distributed - File Systems
29 p | 86 | 5
-
Bài giảng Hệ điều hành nâng cao - Chapter 18: Distributed Coordination
54 p | 88 | 5
-
Bài giảng Hệ điều hành nâng cao - Chapter 16: Distributed System Structures
36 p | 100 | 4
Chịu trách nhiệm nội dung:
Nguyễn Công Hà - Giám đốc Công ty TNHH TÀI LIỆU TRỰC TUYẾN VI NA
LIÊN HỆ
Địa chỉ: P402, 54A Nơ Trang Long, Phường 14, Q.Bình Thạnh, TP.HCM
Hotline: 093 303 0098
Email: support@tailieu.vn