Ceng Operating Systems

Slides:



Advertisements
Similar presentations
Chapter 6 File Systems 6.1 Files 6.2 Directories
Advertisements

Chapter 12: File System Implementation
File Management.
More on File Management
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 4 : File Systems What is a file system?
File Systems.
Allocation Methods - Contiguous
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Long-term Information Storage
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation: beyond the user’s view A possible file system layout on a disk.
Operating Systems File Systems (in a Day) Ch
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems Implementation
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Secondary Storage Management Hank Levy. 8/7/20152 Secondary Storage • Secondary Storage is usually: –anything outside of “primary memory” –storage that.
Contiguous Allocation of Disk Space. Linked Allocation.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
1Fall 2008, Chapter 11 Disk Hardware Arm can move in and out Read / write head can access a ring of data as the disk rotates Disk consists of one or more.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Operating System Concepts and Techniques Lecture 17
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
CS333 Intro to Operating Systems Jonathan Walpole.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
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.
Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
CS450/550 FileSystems.1 Adapted from MOS2E UC. Colorado Springs CS450/550 Operating Systems Lecture 6 File Systems Palden Lama Department of Computer.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
Chapter 16 File Management The Architecture of Computer Hardware and Systems Software: An Information Technology Approach 3rd Edition, Irv Englander John.
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
I MPLEMENTING FILES. Contiguous Allocation:  The simplest allocation scheme is to store each file as a contiguous run of disk blocks (a 50-KB file would.
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems File systems.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
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 Chapter 4 File Systems 文件系统.
W4118 Operating Systems Instructor: Junfeng Yang.
Today topics: File System Implementation
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Chapter 11: File System Implementation
FileSystems.
Chapter 11: File-System Interface
Filesystems.
Chapter 11: File System Implementation
CS510 Operating System Foundations
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Secondary Storage Management Brian Bershad
Chapter 10: File-System Interface
Files Management – The interfacing
Chapter 16 File Management
Chapter 14: File-System Implementation
Secondary Storage Management Hank Levy
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

Ceng 334 - Operating Systems Chapter 4 : File Systems What is a file system? Objectives & user requirements Characteristics of files & directories File system implementation Directory implementation Free blocks management Increasing file system performance Ceng 334 - Operating Systems

Ceng 334 - Operating Systems File System The collection of algorithms and data structures which perform the translation from logical file operations (system calls) to actual physical storage of information Ceng 334 - Operating Systems

Objectives of a File System Provide storage of data and manipulation Guarantee consistency of data and minimise errors Optimise performance (system and user) Eliminate data loss (data destruction) Support variety of I/O devices Provide a standard user interface Support multiple users Ceng 334 - Operating Systems

Ceng 334 - Operating Systems User Requirements Access files using a symbolic name Capability to create, delete and change files Controlled access to system and other users’ files Control own access rights Capability of restructuring files Capability to move data between files Backup and recovery of files Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Files Naming Name formation Extensions (Some typical extensions are shown below) Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Files (Cont.) Structuring (a) Byte sequence (as in DOS, Windows & UNIX) (b) Record sequence (as in old systems) (c) Tree structure (as in some mainframe Oses) Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Files (Cont.) File types Regular (ASCII, binary) Directories Character special files Block special files File access Sequential access Random access Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Files (Cont.) File attributes Read, write, execute, archive, hidden, system etc. Creation, last access, last modification Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Files (Cont.) File operations Create Delete Open Close Read Write Append Seek Get attributes Set Attributes Rename Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Directories Where to store attributes In directory entry (DOS, Windows) In a separate data structure (UNIX) Path names Absolute path name Relative path name Working (current) directory Operations Create, delete, rename, open directory, close directory, read directory, link (mount), unlink Ceng 334 - Operating Systems

Directories & Files (UNIX) / d1 f4 f5 f7 d3 d4 d5 d6 f6 Disk A Disk B Root Directory Linked Branch Working Directory Working directory : d2 Absolute path to file f2 : /d1/d2/f2 Relative path to file f2 : f2 Ceng 334 - Operating Systems

Physical Disk Space Management Sector Heads Cylinder Track Each plate is composed of sectors or physical blocks which are laid along concentric tracks Sectors are at least 512 bytes in size Sectors under the head and accessed without a head movement form a cylinder Ceng 334 - Operating Systems

File System Implementation Contiguous allocation Linked list allocation Linked list allocation using an index (DOS file allocation table - FAT) i-nodes (UNIX) Ceng 334 - Operating Systems

Contiguous Allocation The file is stored as a contiguous block of data allocated at file creation (a) Contiguous allocation of disk space for 7 files (b) State of the disk after files D and E have been removed Ceng 334 - Operating Systems

Contiguous Allocation (Cont.) FAT (file allocation table) contains file name, start block, length Advantages Simple to implement (start block & length is enough to define a file) Fast access as blocks follow each other Disadvantages Fragmentation Re-allocation (compaction) Ceng 334 - Operating Systems

Linked List Allocation The file is stored as a linked list of blocks Ceng 334 - Operating Systems

Linked List Allocation (Cont.) Each block contains a pointer to the next block FAT (file allocation table) contains file name, first block address Advantages Fragmentation is eliminated Block size is not a power of 2 because of pointer space Disadvantages Random access is very slow as links have to be followed Ceng 334 - Operating Systems

Linked list allocation using an index (DOS FAT) Disk size EOF 1 Free 5 7 Bad ….. 3 2 4 6 FAT (File allocation table) File blocks n First block address is in directory entry Ceng 334 - Operating Systems

Linked list allocation using an index (Cont.) The DOS (Windows) FAT is arranged this way All block pointers are in FAT so that don’t take up space in actual block Random access is faster since FAT is always in memory 16-bit DOS FAT length is (65536+2)*2 = 131076 bytes Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Problem 16-bit DOS FAT can only accommodate 65536 pointers (ie., a maximum of 64 MB disk) How can we handle large disks such as a 4 GB disk? Clustering Ceng 334 - Operating Systems

i (index)-nodes (UNIX) File mode Number of links UID GID File size Time created Time last accessed Time last modified 10 disk block numbers Single indirect block Triple indirect block Double indirect block Indirect blocks Data blocks Ceng 334 - Operating Systems

Ceng 334 - Operating Systems i-nodes (Cont.) Assume each block is 1 KB in size and 32 bits (4 bytes) are used as block numbers Each indirect block holds 256 block numbers First 10 blocks : file size <= 10 KB Single indirect : file size <= 256+10 = 266 KB Double indirect : file size <= 256*256 +266 = 65802 KB = 64.26 MB Triple indirect : file size <= 256*256*256 + 65802= 16843018 KB = ~16 GB Ceng 334 - Operating Systems

Directory Implementation DOS (Windows) directory structure UNIX directory structure Ceng 334 - Operating Systems

DOS (Windows) Directory Structure (32 bytes) File name Ext A Reserved T P D Size 8 bytes 3 1 10 2 4 Date of creation Time of creation Attributes (A,D,V,S,H,R) Pointer to first data block Ceng 334 - Operating Systems

UNIX Directory Structure (16 bytes) I-node # File name 2 bytes 14 bytes Ceng 334 - Operating Systems

The Windows 98 Directory Structure Extended MS DOS Directory Entry An entry for (part of) a long file name Ceng 334 - Operating Systems

The Windows 98 Directory Structure An example of how a long name is stored in Windows 98 Ceng 334 - Operating Systems

Path Name Lookup : /usr/ast/mbox 245 Root (/) i-node 1 . .. 4 bin 7 dev 14 lib 9 etc 6 usr Root directory file block 245 132 i-node 6 of /usr 6 . 1 .. 19 prog 30 stu 51 html 26 ast 45 genc /usr directory file block 132 26 . 6 .. 60 mbox 92 books 81 src /usr/ast directory file block 406 i-node 60 of /usr/ast/mbox 406 i-node 26 of /usr/ast Blocks of file Ceng 334 - Operating Systems

Two ways of handling long file names in a Directory In-line In a heap Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Shared Files / d1 d2 f1 f2 f3 File f2 is shared by two paths (users!) and there is one physical copy. The directories d1 & d2 point to the same i-node with link count equal to 2 Deletion is done by decrementing the link count. When it reaches zero the file is deleted physically Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Disk Space Management Block size Dark line (left hand scale) gives data rate of a disk Dotted line (right hand scale) gives disk space efficiency All files 2KB Ceng 334 - Operating Systems

How to Keep Track of Free Disk Blocks Linked list of disk blocks Bit maps Indexing as used in DOS FAT Ceng 334 - Operating Systems

Linked List of Disk Blocks Allocation is simple. Delete block number from free blocks list Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Bit Maps The bit map is implemented by reserving a bit string whose length equals the number of blocks A ‘1’ may indicate that the block is used and ‘0’ for free blocks If the disk is nearly full then the bit map method may not be as fast as the linked list method Ceng 334 - Operating Systems

Increasing File System Performance Disks (floopies, hard disks, CD ROMS) are still slow when compared to the memory Use of a memory cache may speed the disk transfers between disk and process Blocks are read into the cache first. Subsequent accesses are through the cache Blocks are swapped in & out using replacement algorithms such as FIFO, LRU System crashes may cause data loss if modified blocks are not written back to disk Ceng 334 - Operating Systems

Where to Put the Current “File Position” Field The file position field is a 16 or 32 bit variable which holds the address of the next byte to be read or written in a file Put it in the i-node Put it in process table Ceng 334 - Operating Systems

File Position Field in i-node If two or more processes share the same file, then they must have a different file position Since i-node is unique for a file, the file position can not be put in the i-node Ceng 334 - Operating Systems

File Position Field in Process Table When a process forks, both the parent and the child must have the same file position Since the parent and the child have different process tables they can not share the same file position So, we can not put in process table Ceng 334 - Operating Systems

Ceng 334 - Operating Systems Solution Use an intermediate table for file positions parent child Process tables position File positions table i-node of file Ceng 334 - Operating Systems