intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface

Chia sẻ: Xaydung K23 | Ngày: | Loại File: PPTX | Số trang:43

100
lượt xem
10
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

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.

Chủ đề:
Lưu

Nội dung Text: Bài giảng Hệ điều hành nâng cao - Chapter 10: File - System Interface

  1. Chapter 10: File-System Interface Operating System Concepts – 8th Edition Operating System Concepts – 8th Edition 10.1 Silberschatz, Galvin and Gagne ©2009
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. File Types – Name, Extension Operating System Concepts – 8th Edition 10.12 Silberschatz, Galvin and Gagne ©2009
  13. 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
  14. Sequential-access File Operating System Concepts – 8th Edition 10.14 Silberschatz, Galvin and Gagne ©2009
  15. Simulation of Sequential Access on Direct-access File Operating System Concepts – 8th Edition 10.15 Silberschatz, Galvin and Gagne ©2009
  16. Example of Index and Relative Files Operating System Concepts – 8th Edition 10.16 Silberschatz, Galvin and Gagne ©2009
  17. 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
  18. 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
  19. A Typical File-system Organization Operating System Concepts – 8th Edition 10.19 Silberschatz, Galvin and Gagne ©2009
  20. 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
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
42=>0