Lecture Operating systems: A concept-based approach (2/e): Chapter 7 - Dhananjay M. Dhamdhere

66 54 0
Lecture Operating systems: A concept-based approach (2/e): Chapter 7 - Dhananjay M. Dhamdhere

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 7 - File systems. This chapter discusses a programmer’s view of files and the file system. It describes fundamental file organizations, directory structures, operations on files and directories, and file sharing semantics, which specify the manner in which results of file manipulations performed by concurrent processes are visible to one another.

PROPRIETARY MATERIAL. ©  2007 The McGraw­Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide  may be displayed, reproduced or distributed  in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw­Hill  for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission.  Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 1  Copyright © 2008 Goals of a File system • Convenient and fast access to files – Different file organizations to suit different user requirements • Reliable storage of files – Prevents damage due to crashes, etc • Controlled sharing of files – Unauthorized persons should not be able to access files • … also ensure efficient use of I/O devices – We discuss this aspect in Chapter 12 Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 2  Copyright © 2008 Structure of a File system • A file system is structured into a hierarchy of layers – File system layer * Deals with files as objects  Creates files, allocates disk space to them  Implements file sharing and prevents unauthorized access  Prevents damage due to crashes – Input-Output Control System (IOCS) layer * Implements file system operations, ensuring  Efficient access to records in files  Efficient operation of I/O devices Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 3  Copyright © 2008 File system and IOCS layers • Each layer contains policy and mechanism modules • A mechanism module invokes modules of the lower layer Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 4  Copyright © 2008 File system • A Directory – Groups a set of files * It contains an entry for each of these files * The entry contains information useful for accessing the file – Users have different directories * Helps to separate files of different users * Provides file naming freedom – Directories are organized in a hierarchical structure * Permits a user to organize her files logically, e.g., according to activities Chapter 7: File Systems Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:5 Copyrightâ2008 Logical organization in file systems ã Two files named beta exist The file system must open the correct one when a process executes open (beta, ) • Records may be organized differently in different files Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 6  Copyright © 2008 Logical organization in file systems • Comments on the previous slide – Two files named beta exist in the file system * Thus users enjoy file naming freedom – Processes Pi and Pj share one of these files * The rules of sharing are determined by file sharing semantics – Files beta and phi have different organizations and are accessed differently * File beta is a sequential file; its records are read in a sequence * File phi is a direct file; its records can be read in random order Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 7 Copyrightâ2008 Overview of file processing ã Implementation of file processing activities – File processing activities are implemented through combined actions of a compiler, modules of the file system and IOCS, and the kernel * The compiler replaces open and read/write statements in a program with calls on file system and IOCS modules  These modules implement the desired file operations  These file system and IOCS modules are linked to the program * A process executing the program invokes these modules during its operation to perform file operations  The modules may make system calls to invoke functionalities of the kernel Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 8  Copyright © 2008 File processing in a program Source program compiled program linked program • The program invokes file system modules during execution • File system modules invoke the IOCS modules Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 9 Copyrightâ2008 File Types ã Files can be of two types – Structured files * A File contains records * Each record contains a key field  Key fields of records in a file contain unique values * Records in a file can be accessed in different ways  Sequential access  Random access by specifying the key value of a record – Byte-stream files * A file is merely a stream of bytes Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 10  Copyright © 2008 Fault tolerance using the stable storage technique • If both copies are readable but different, use the primary copy • Can we differentiate between cases (a) and (d)? Chapter 7: File Systems Dhamdhere: Operating Systems— AConceptưBasedApproach,2ed SlideNo:52 Copyrightâ2008 Atomic actions ã If many data items are to be updated in a mutually consistent manner – When a crash occurs, some of the data items may have been updated but others may not have been – For example, while transferring funds from one bank account to another * An amount may be deducted from one account, but it may not be added to another account * Or it may be added to an account without being deducted from another! • An atomic action helps in ensuring mutual consistency of data Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 53  Copyright © 2008 Atomic actions • An atomic action updates data items in a mutually consistent manner – It has the all-or-nothing property * All updates indicated in an atomic action are performed if the atomic action commits  The process executing an atomic action declares a ‘commit’ after it has performed all subactions in the atomic action  All of its updates are performed even if a failure occurs after it commits * If a failure occurs before the atomic action commits, none of its updates are performed Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  SlideNo:54 Copyrightâ2008 Atomic action add_a_block ã The atomic action adds disk block dj to a file after block d1, in a file system using linked allocation • Either d1 and dj should both be updated, or none should be Chapter 7: FileSystems Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:55 Copyrightâ2008 Atomic actions ã An atomic action can be implemented in several ways, we discuss a method using an intentions list – A commit flag takes the values ‘committed’ and ‘not committed’ * It is initially ‘not committed’ – Updates to files are merely written into an intentions list (also called a todo log); they are not performed directly in files – When the ‘end transaction’ statement is executed * The commit flag is set to ‘committed’ * Updates are carried out using the intentions list * The commit flag is destroyed after all updates are made – If failures occur * The updating procedure is performed (or repeated) if the commit flag is ‘committed’ Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 56  Copyright © 2008 Implementation of atomic action add_a_block (a) During execution of the atomic action: The commit flag has the value ‘not committed’ Updates are written into the intentions list Each entry shows the new value to be written into a block (b) Situation after commit; dj has been inserted between d1 and d2 Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  SlideNo:57 Copyrightâ2008 Virtual file system (VFS) ã Users have diverse requirements of a file system – A single file system may not be able to meet all of them – Hence, several file systems must operate in parallel so that a user can use the file system of her choice – A virtual file system fulfills this requirement * It supports parallel operation of many file systems * The VFS provides generic file operations  When a process invokes a generic file operation on a file, the VFS invokes an operation of the specific file system that contains the file * The VFS contains only meta data, i.e control data Chapter7: FileSystems Dhamdhere:OperatingSystems AConceptưBasedApproach,2ed SlideNo:58 Copyrightâ2008 Virtual file system ã The VFS contains only meta data • When a process requests an operation on a file, VFS invokes the appropriate file system Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 59  Copyright © 2008 File system performance • To ensure good performance, special techniques are used to speed up the following aspects – Directory access * A directory cache is used to speed up directory access – Directory search * Directory is organized as a hash table or B+ tree – Access to file map table * An FMT cache is maintained in memory – Accessing a disk block * Disk block cache, cylinder groups, disk scheduling (Chapter 12) – Accessing data * Buffering and blocking of data (Chapter 12) Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 60  Copyright © 2008 Log structured file systems • A log structured file system helps reduce disk head movement through a radically different file organization – It writes all files together into a single sequential file called the log file * Hence disk heads need not be moved between consecutive write operations; they are moved only for read operations – The file system periodically writes index blocks to contain control data about files * The index blocks indicate where records of a file are located (analogous to FMT) • Sprite file system: disk head movement consumed only 30% of time as against about 90% in Unix file system Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 61  Copyright © 2008 Unix file system • File system data structures – A directory entry contains only the file name – Inode of a file contains file size, owner id, access permissions and disk block allocation information – A file structure contains information about an open file * It contains current position in file, and pointer to inode of the file – A file descriptor points to a file structure * File descriptors are kept in a table of open files – Indexed allocation uses up to levels of indirection • Unix file sharing semantics – Result of a write performed by a process is immediately visible to all other processes currently accessing the file Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 62  Copyright © 2008 Unix data structures • The file descriptor and file structure are together equivalent to the FCB • File descriptors are stored in a table analogous to AFT Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  SlideNo:63 Copyrightâ2008 Unix file allocation table ã 12 entries of the table directly point to data blocks • One entry each is used for single indirection, double indirection and triple indirection Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 64  Copyright © 2008 Linux file system • • Linux provides a virtual file system (VFS) File system Ext2 provides several kinds of locks – Advisory locks are not enforced by the file system, but users may utilize them – Mandatory locks are used to ensure only one user uses a file – Lease locks are valid for a specific amount of time * They provide mutual exclusion, but mutual exclusion is not indefinite – It allocates several consecutive disk blocks together to reduce disk head movement • File system Ext3 provides journaling – It supports modes to reduce or eliminate loss of data and meta data when failures occur Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 65  Copyright © 2008 Windows file system • • NTFS meets requirements for servers and workstations Space allocation and data structures – Disk space allocation is in terms of clusters of blocks – A file has attributes stored in the MFT File data is also an attribute – Large attributes are stored elsewhere on a disk as non-resident attributes – Directories are implemented using B+ trees • Robustness – Every update of control data is implemented as an atomic action – RAID architecture is used to avoid loss of user data – Additionally, a checkpoint, which resembles a back-up, is taken every seconds Chapter 7: File Systems Dhamdhere: Operating Systems— A Concept­Based Approach, 2ed  Slide No: 66  Copyright © 2008 ... allocation • Data and meta data – Data written into a file is called file data * A disk block containing only file data is called a data block – Data used by the file system to control its own operation... FileSystems Dhamdhere: OperatingSystems AConceptưBasedApproach,2ed SlideNo:31 Copyrightâ2008 File allocation table (FAT) ã FAT is a variant of linked allocation – It stores the control data separately... FileSystems Dhamdhere: OperatingSystems AConceptưBasedApproach,2ed SlideNo:20 Copyrightâ2008 Directory graphs ã Links A link provides an alternative method of naming a file * It associates a name in a

Ngày đăng: 30/01/2020, 00:53

Từ khóa liên quan

Mục lục

  • Slide 1

  • Goals of a File system

  • Structure of a File system

  • File system and IOCS layers

  • File system

  • Logical organization in file systems

  • Slide 7

  • Overview of file processing

  • File processing in a program

  • File Types

  • Records and fields in a file

  • File operations performed by processes

  • File organizations

  • Slide 14

  • Sequential and direct files

  • An Index Sequential file

  • A typical directory entry

  • Two-level directories: Master and user directories

  • Generalizations of the two-level directory structure

  • Sample directory hierarchy

Tài liệu cùng người dùng

Tài liệu liên quan