File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.

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
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.
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.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
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
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.
Access Methods File store information When it is used it is accessed & read into memory Some systems provide only one access method IBM support many access.
Allocation Methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation.
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.
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.
File and File–System Management
Chapter 10: File-System Interface
Module 10: File-System Interface
Presentation transcript:

File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program

File Structure §None - sequence of words, bytes §Simple record structure: l Lines l Fixed length l Variable length §Complex Structures: l Formatted document l Relocatable load file

File Structure (cont) §Can simulate last two with first method by inserting appropriate control characters. §Who decides: l Operating system l Program

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.

File Attributes (cont) §Time, date, and user identification – data for protection, security, and usage monitoring. §Information about files is kept in the directory structure, that is maintained on the disk.

File Operations  create  write  read  reposition within file – file seek  delete  truncate  open(F i ) – search the directory structure on disk for entry F i, and move the content of entry to memory.  close (F i ) – move the content of entry F i in memory to directory structure on disk.

File Types – name, extension

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

Directory Structure §A collection of nodes containing information about all files. F 1 F 2 F 3 F 4 F n Directory Files Both the directory structure and the files reside on disk. Backups of these two structures are kept on tapes.

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)

Operations Performed on Directory §Search for a file §Create a file §Delete a file §List a directory §Rename a file §Traverse the file system

Organize the Directory Logically to Obtain: §Efficiency – locating a file quickly. §Naming – convenient to users. l Two users can have same name for different files. l The same file can have several different names. §Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …)

Single-Level Directory §A single directory for all users. Naming problem. Grouping problem.

Two-Level Directory §Separate directory for each user. Path name. Can have the same file name for different user. Efficient searching. No grouping capability.

Tree-Structured Directories

Tree-Structured Directories (cont) §Efficient searching §Grouping Capability §Current directory (working directory) cd /spell/mail/prog type list

Tree-Structured Directories (cont) §Absolute or relative path name §Creating a new file is done in current directory.  Delete a file: rm  Creating a new subdirectory is done in current directory: mkdir Example: if in current directory /spell/mail: mkdir count

Tree-Structured Directories (cont)  Deleting mail implies that all subdirectories and files are also deleted. mail progcopyprtexpcount

Acyclic-Graph Directories §Have shared subdirectories and files.

Acyclic-Graph Directories (cont) §Two different names (aliasing)  If dict deletes list  dangling pointer. Solutions: l Backpointers, so we can delete all pointers. Variable size records a problem. l Backpointers using a daisy chain organization. l Entry-hold-count solution.

General Graph Directory

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

Protection §File owner/creator should be able to control: l What can be done. l By whom. §Types of access: l Read l Write l Execute l Append l Delete l List

Access Lists and Groups §Mode of access: read, write, execute §Three classes of users: l Owner access – 7 (111) – RWX l Group access – 6 (110) – RW l Public access – 1 (001) – X §Ask manager to create a group (unique name), say G, and add some users to the group.

Access Groups and Lists (cont) §For a particular file (say game) or subdirectory, define an appropriate access. §Attach a group to a file chgrp G game ownergrouppublic chmod761game

File-System Structure §File structure: l Logical storage unit. l 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.

Contiguous Allocation §Each file occupies a set of contiguous blocks on the disk. §Simple – only starting location (block number) and length (number of blocks) are required. §Random access. §Wasteful of space (dynamic storage- allocation problem). §Files cannot grow.

Contiguous Allocation (cont) §Mapping from logical to physical. l Block to be accessed = Q + starting address. l Displacement into block = R. LA/512 Q R

Linked Allocation §Each file is a linked list of disk blocks: l Blocks may be scattered anywhere on the disk. pointer block =

Linked Allocation (cont) §Allocate as needed, link together; e.g., file starts at block 9.

Linked Allocation (cont) §Simple – need only starting address §Free-space management system – no waste of space §No random access §Mapping l Block to be accessed is the Q th block in the linked chain of blocks representing the file. l Displacement into block = R + 1. LA/511 Q R

Linked Allocation (cont) §File-allocation table (FAT) – disk space allocation used by MS-DOS and OS/2.

Indexed Allocation §Brings all pointers together into the index block. §Logical view. index table

Example of Indexed Allocation

Indexed Allocation (cont) §Need index table. §Random access. §Dynamic access without external fragmentation, but have overhead of index block.

Index Allocation (cont) §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. l Q = displacement into index table. l R = displacement into block. LA/512 Q R

Indexed Allocation – Mapping (cont) §Mapping from logical to physical in a file of unbounded length (block size of 512 words).

Indexed Allocation – Mapping (cont) §Linked scheme – Link blocks of index table (no limit on size). l Q 1 = block of index table l R 1 is used as follows: l Q 2 = displacement into block of index table l R 2 displacement into block of file. LA / (512 x 511) Q1Q1 R1R1 R 1 / 512 Q2Q2 R2R2

Indexed Allocation – Mapping (cont) §Two-level index (maximum file size is ) l Q 1 = displacement into outer-index l R 1 is used as follows: l Q 2 = displacement into block of index table l R 2 displacement into block of file. LA / (512 x 512) Q1Q1 R1R1 R 1 / 512 Q2Q2 R2R2

Indexed Allocation – Mapping (cont) outer-index index table file

Combined Scheme: UNIX (4K bytes per block)

Free Space Management §Bit vector (n blocks) §Block number calculation: … 012n-1 bit[i] = 0  block[i] free 1  block[i] occupied (number of bits per word) * (number of 0-value words) + offset of first 1 bit

Free Space Management (cont) §Bit map requires extra space. Example: block size = 2 12 bytes disk size = 2 30 bytes (1 gigabyte) n = 2 30 /2 12 = 2 18 bits (or 32K bytes) §Easy to get contiguous files §Linked list (free list) l Cannot get contiguous space easily l No waste of space §Grouping §Counting

Free Space Management (cont) §Need to protect: l Pointer to free list l 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. l Solution: Set bit[i] = 1 in disk. Allocate block[i] Set bit[i] = 1 in memory

Directory Implementation §Linear list of file names with pointer to the data blocks. l Simple to program. l Time consuming to execute. §Hash Table – linear list with hash data structure. l Decreases directory search time. l Collisions – situations where two file names hash to the same location. l Fixed size.

Efficiency and Performance §Efficiency dependent on: l Disk allocation and directory algorithms. l Types of data kept in file’s directory entry. §Performance l Disk cache – separate section of main memory for frequently sued blocks. l Free-behind and read-ahead – techniques to optimize sequential access. l Improve PC performance by dedicating section of memory as virtual disk, or RAM disk.

Various Disk-Caching Locations

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.