File and File–System Management

Slides:



Advertisements
Similar presentations
Chapter 10: File-System Interface
Advertisements

1 Chapter 11: File-System Interface  File Concept  Access Methods  Directory Structure  File System Mounting  File Sharing  Protection  Chapter.
Chapter 10: File-System Interface
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
Chapter 10: File-System Interface
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Dr. Kalpakis CMSC 421, Operating Systems. Fall File-System Interface.
1 File Management (a). 2 File-System Interface  File Concept  Access Methods  Directory Structure  File System Mounting  File Sharing  Protection.
Chapter 11: File System Implementation
04/02/2004CSCI 315 Operating Systems Design1 File System Interface.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
File System Implementation
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File-System Interface.
04/05/2010CSCI 315 Operating Systems Design1 Virtual Memory Wrap-up; File System Interface.
Chapter 12: File System Implementation
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
Chapter 10: File-System Interface
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
04/05/2004CSCI 315 Operating Systems Design1 File System Implementation.
File System Implementation
File Concept l Contiguous logical address space l Types: Data: numeric, character, binary Program: source, object (load image) Documents.
Os111 Chapter 11 File-System Interface. os112 Outline File Concept Access Methods Directory Structure File System Mounting File Sharing Protection.
04/07/2010CSCI 315 Operating Systems Design1 File System Implementation.
03/30/2007CSCI 315 Operating Systems Design1 Virtual Memory cont’d.; File System Interface.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10: File-System Interface.
ICS Principles of Operating Systems Lectures 14 and 15 - FileSystem Interface and Implementation Prof. Nalini Venkatasubramanian
ITEC 502 컴퓨터 시스템 및 실습 Chapter 10-1: File Systems Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne  Operating System Concepts File Concept Contiguous logical address space Smallest user allocation Non-volatile.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Chap 10 File-System Interface. Objectives To explain the function of file systems To describe the interfaces to file systems To discuss file-system design.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Chapter 10: File-System.
Chapter 10: File-System Interface 10.1 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts – 8 th Edition 2014.
Page 110/19/2015 CSE 30341: Operating Systems Principles Chapter 10: File-System Interface  Objectives:  To explain the function of file systems  To.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Structure.
File-System. Overview File system is the visible aspect of an OS. It provides mechanism for on-line storage of and access to both data and programs of.
Dr. T. Doom 11.1 CEG 433/633 - Operating Systems I Chapter 11: File-System Implementation File structure –Logical storage unit –Collection of related information.
Silberschatz and Galvin  Operating System Concepts File-System Implementation File-System Structure Allocation Methods Free-Space Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 11: File-System Interface File Concept Access Methods Directory Structure.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
10.1 CSE Department MAITSandeep Tayal 10 :File-System Implementation File-System Structure Allocation Methods Free-Space Management Directory Implementation.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 11 File-System Implementation Slide 1 Chapter 11: File-System Implementation.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 10: File-System Interface File Concept.
Silberschatz and Galvin  Operating System Concepts Module 10: File-System Interface File Concept Access :Methods Directory Structure Protection.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File-System Interface.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 11: File-System Interface File Concept Access Methods Directory Structure.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems File System Interface.
ICS Principles of Operating Systems Lectures 14 and 15 - FileSystem Interface and Implementation Prof. Nalini Venkatasubramanian
CSE Operating System Principles File Systems.
Lecture : chapter 9 and 10 file system 1. File Concept A file is a collection of related information defined by its creator. Contiguous logical address.
Chapter 13: File-System Interface
File-System Implementation
Module 10: File-System Interface
Chapter 11: File-System Interface
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
Chapter 10: File-System Interface
Module 10: File-System Interface
Presentation transcript:

File and File–System Management CS 502 Spring 99 WPI MetroWest/Southboro Campus

File and File–System Management Outline File–System Interface File Concept Access Methods Directory Structure Protection Consistency Semantics File–System Implementation File­System Structure Allocation Methods Free­Space Management Directory Implementation Efficiency and Performance Recovery 1/15/2019

File Concept Contiguous logical address space Types: Data Program numeric character binary Program source object (load image) Documents 1/15/2019

File 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 Program 1/15/2019

File 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 disk. 1/15/2019

File Operations create write read reposition within file – file seek 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 Fi in memory to directory structure on disk. 1/15/2019

File Types – name.extension 1/15/2019

Access Methods Sequential Access Direct Access read next write next reset no read after last write (rewrite) Direct Access read n write n position to n rewrite n n = relative block number 1/15/2019

Directory Structure A collection of nodes containing information about all files. Both the directory structure and the files reside on disk. Backups of these two structures are kept on tapes. Directory F1 F2 F3 Fn Files 1/15/2019

Information in a Device Directory Name Type Address Current length Maximum length Date last accessed (for archival) Date last updated (for dump) Owner ID (who pays) Protection information (discuss later) 1/15/2019

Operations Performed on a Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system 1/15/2019

Organize 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 Pascal programs, all games, ...) 1/15/2019

Single–Level Directory A single directory for all users. Naming problem Grouping problem cat bo a test data mail cont hex records Directory Files 1/15/2019

Two–Level Directory Separate directory for each user. Path name – absolute and relative Can have the same file name for different user Efficient searching No grouping capability Master File Directory User 1 User 2 User 3 User 4 User File Directory cat bo a test a data a test x data a 1/15/2019

Tree–Structured Directories spell bin programs root stat mail dist find count hex reorder p e mail test a data a find list reorder hex count list obj spell all last first 1/15/2019

Tree–Structured Directories (Cont.) Efficient searching Grouping capability New concept of the current directory (working directory) cd /spell/mail/prog type list Absolute or relative path names Implicit relative operations Create a file Delete a file Create a subdirectory Deletion semantics Entire subtree or ensure empty subtree 1/15/2019

Acyclic–Graph Directories Ability to share subdirectories and files dict spell root list all w count count words list list rade w7 1/15/2019

Acyclic–Graph Directories (Cont.) Two different names (aliasing) If dict deletes list Þ dangling pointer. Solutions: Backpointers, so we can delete all pointers. Variable size records a problem. Backpointers using a daisy chain organization. Entry­hold­count solution. 1/15/2019

General Graph Directory tcb rcbc glade root papers mail unhex hyp text mail count papers tcb count unhex hex 1/15/2019

General Graph Directory (Cont.) How do we guarantee no cycles? Allow only links to file not subdirectories. Garbage collection. Every time a new link is added use a cycle detection algorithm to determine whether it is OK. 1/15/2019

Protection File owner/creator should be able to control: what can be done by whom Types of access Read Write Execute Append Delete List 1/15/2019

Access Lists and Groups Mode of access: read, write, execute RWX, R = 4; W=2; X=1 Three classes of users owner access 7 Þ 1 1 1 groups access 6 Þ 1 1 0 public access 1 Þ 0 0 1 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. chmod 761 game Attach a group to a file chgrp G game 1/15/2019

Consistency Semantics Specify “what happens” when multiple users access a shared file concurrently: File Session – set of operations bracketed by open and close. Unix Semantics writes to a file are visible to concurrent sessions common file pointer sharing Session Semantics writes to a file are not visible to concurrent sessions Upon a close, updates are visible to successor sessions Immutable Shared File semantics 1/15/2019

File–System Implementation File­System Structure Allocation Methods Free­Space Management Directory Implementation Efficiency and Performance Recovery 1/15/2019

File–System Structure File structure Logical storage unit Collection of related information File system resides on secondary storage (disks). File system organized into layers. File control block – storage structure consisting of information about a file. File Allocation Table – collection of file control block information 1/15/2019

File–System Software Architecture User Program Indexed Sequential Pile Sequential Indexed Hashed Logical I/O Basic I/O Supervisor Basic File System Disk Device Driver Tape Device Driver 1/15/2019

Device Drivers Lowest level Communicates directly with peripheral devices Responsible for starting I/O operations on a device Processes the completion of an I/O request 1/15/2019

Basic File System Physical I/O Deals with exchanging blocks of data Concerned with the placement of blocks Concerned with buffering blocks in main memory 1/15/2019

Basic I/O Supervisor Responsible for file I/O initiation and termination Control structures are maintained Concerned with scheduling access to optimize performance Part of the operating system 1/15/2019

Logical I/O Allows users and applications to access records Maintains basic data about file 1/15/2019

Access Method Reflect different file structures Different ways to store and process data 1/15/2019

Contiguous Allocation Each file occupies a set of contiguous blocks on the disk. Simple – only starting location (block #) and length (number of blocks) are required. Random access. Wasteful of space (dynamic storage­allocation problem). Files cannot grow. Mapping from logical to physical. LA/512: Quotient Q, Remainder R Block to be accessed = Q + starting address Displacement into block = R 1/15/2019

Contiguous File Allocation File Allocation Table FileA File Name Start Block Length 1 2 3 4 FileA 2 3 FileB 9 5 5 6 7 8 9 FileC 18 8 FileB FileD 30 2 10 11 12 13 14 FileE 26 3 15 16 17 18 19 FileC 20 21 22 23 24 FileE 25 26 27 28 29 FileD 30 31 32 33 34

Linked Allocation Allocation on basis of individual block Each block contains a pointer to the next block in the chain Only single entry in the file allocation table starting block and length of file No fragmentation Any free block can be added to the chain No accommodation of the principle of locality – no random access. LA/511 Quotient Q; Remainer R Block to be accessed is the Qth block in the linked chain of blocks representing the file. Displacement into block = R+1 1/15/2019

Linked File Allocation File Allocation Table FileB File Name Start Block Length 1 2 3 4 ... ... ... FileB 1 5 5 6 7 8 9 ... ... ... 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

Indexed Allocation Brings all pointers together into an index block. Logical view: 1/15/2019

Indexed Allocation with Block Portions File Allocation Table FileB File Name Index Block 1 2 3 4 ... ... 5 6 7 8 9 FileB 24 ... ... 10 11 12 13 14 15 16 17 18 19 1 8 20 21 22 23 24 3 14 25 26 27 28 29 28 -1 30 31 32 33 34

Indexed Allocation (Cont.) Need index table Random access Dynamic access without external fragmentation, but have overhead of index block. Mapping from logical to physical in a file of maximum size of 256K words and block size of 512 words. We need only 1 block for index table. LA/512 Q = displacement into index table R = displacement into block 1/15/2019

Indexed Allocation - Var Length Portions File Allocation Table FileC File Name Index Block 1 2 3 4 ... ... 5 6 7 8 9 FileC 24 ... ... 10 11 12 13 14 15 16 17 18 19 Start Block Length 20 21 22 23 24 1 3 28 4 14 1 25 26 27 28 29 30 31 32 33 34

Indexed Allocation – Mapping (Cont.) Mapping from logical to physical in a file of unbounded length (block size of 512 words). Linked scheme -- Link blocks of index tables (no limit on size). LA/(512 x 511) Q 1 block of index table R 1 is used as follows: R 1 / 512 Q 2 = displacement into block of index table R 2 = displacement into block of file 1/15/2019

Indexed Allocation – Two Level Index Directory Outer–index Index Table File 1/15/2019

Unix File Allocation (4K bytes per block) Mode data Owners (2) Timestamps (3) data Size Block data Count Direct Blocks data data data data data Single Indirect Double Indirect data Triple Indirect data 1/15/2019

Free–Space Management Bit vector (n blocks) bit[i] = 0 Þ block[i] free 1 Þ block[i] occupied Block number calculation (number of bits per word) * (number of 0­value words) + offset of first 1 bit 1 2 3 4 5 6 7 n-1 ... 1/15/2019

Free–Space Management (Cont.) Bit map requires extra space. Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230 / 212 = 218 bits (or 32K bytes) Easy to get contiguous files Linked list (free list) Cannot get contiguous space easily No waste of space Grouping Counting 1/15/2019

Free–Space Management (Cont.) Need to protect: Pointer to free list Bit map Must be kept on disk. Copy in memory and disk may differ. Cannot allow for block[i] to have a situation where bit[i] = 1 in memory and bit[i] = 0 on disk. Solution: Set bit[i] = 1 in disk. Allocate block[i]. Set bit[i] = 1 in memory. 1/15/2019

Directory Implementation Linear list of file names with pointers to the data blocks. simple to program time­consuming to execute Hash Table – linear list with hash data structure. decreases directory search time collisions – situations where two file names hash to the same location fixed size 1/15/2019

Efficiency and Performance Efficiency dependent on: disk allocation and directory algorithms types of data kept in file's directory entry Performance disk cache – separate section of main memory for frequently used blocks free­behind and read­ahead -- techniques to optimize sequential access improve PC performance by dedicating section of memory as virtual disk, or RAM disk 1/15/2019

Various Disk–Caching Locations ram disk track buffer CPU Controller disk open-file table block buffer Main memory 1/15/2019

Recovery Consistency checker – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies. Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape). Recover lost file or disk by restoring data from backup. 1/15/2019