File Management Computer can store information on storage media such as magnetic disks, tape and so on. The physical storage is converted into logical.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
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.
Chapter 10: File-System Interface
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
Chapter 10: File-System Interface
Chapter 11: File System Implementation
File System Implementation
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.
1 File Management Chapter File Management File management system consists of system utility programs that run as privileged applications Input to.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
04/05/2004CSCI 315 Operating Systems Design1 File System Implementation.
File Management.
File System Implementation
File Management Chapter 12.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
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.
Chapter pages1 File Management Chapter 12.
Operating Systems CMPSC 473 I/O Management (4) December 09, Lecture 25 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
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.
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.
1 File Management Chapter File Management n File management system consists of system utility programs that run as privileged applications n Concerned.
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.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
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.
Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  File system structure – layered, block based.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
Fall 2000M.B. Ibáñez Lecture 24 File-System III File System Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
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.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
SVBIT SUBJECT:- Operating System TOPICS:- File Management
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 Management
File System Implementation
File Management Chapter 12.
File-System Implementation
Chapter 12 File Management
Chapter 11: File-System Interface
File System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
EECE.4810/EECE.5730 Operating Systems
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
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.
Overview: File system implementation (cont)
File-System Structure
Operating System Chapter 12. File Management
Files Management – The interfacing
Chapter 16 File Management
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
Presentation transcript:

File Management Computer can store information on storage media such as magnetic disks, tape and so on. The physical storage is converted into logical storage by OS. The logical storage unit is said to be a “File”. Files are mapped by the operating system onto physical devices. A File is a collection of similar records. A record is a collection of related fields that can be treated as a unit by some application program. A field is the some basic element of data. Any individual field contains single value.

File Attributes Name—human readable form Identifier –non human readable name (unique identifier) Type—type supported Location—pointer to the device and to the location of the file on that device Size—number of bytes Protection—read, write and execute permissions Time & Date—creation, last modification and last use info User Identification—name of logged in user The information about file is stored in secondary memory mainly called the directory entry.

File Operations Creating a file—allocate free space on disk and make entry in the directory Writing to File—system call to write name of the file and to write the data Reading from file—keep the read pointer to the location of the file Repositioning with in a file—search the directory for current position and reposition the file pointer to new position Deleting files—release all file space and erase directory entry Truncating files—erase the contents of the file but keep the attributes

File Types

File Management System A file management system (FMS) is a collection of system software programs that provides services to the users. It’s objectives are: To provide the I/O support for multi users. To provide a standardize set of I/O interface routines. Storage of data To optimize the performance To provide I/O support for a variety of storage device types. To guarantee that the data in the file are valid.

File System Architecture User Program Sequential Indexed Sequential Indexed Hashed Logical I/O Basic I/O supervisor Basic File System Disk device driver Tape device driver

File System Architecture At the lowest level, device driver directly communicate with peripheral devices or controllers or channels. A device driver is responsible for starting I/O operations on a device and processing the completion of I/O request. The next level is the “basic file system”. It is the interface with the environment outside of the computer system. The “Basic I/O supervisor” is responsible for all I/O initiation and termination. “Logical I/O” enables users and applications to access records.

File Accessing Methods Files stores information, this information must be accessed and read in to computer memory. There are so many ways that the information in the file can be accessed. Sequential Access Direct Access Indexed sequential

Sequential File Access This method is the simplest of all methods. Information in the file is processed in order, one record after another. Example: editors. compilers For example, a file consisting of 100 records, the current position of read/write head is 45th record. Suppose we want to read 75th record then it access sequentially from 45, 46,47………73,74,75. So the read/write head traverse all the records between 45 to 75. Sequential files are typically used in batch application and payroll applications. Current Position Target Position end Beginning

Direct Access Direct access is called relative access. In this method, records can read/write randomly without any order. The direct access method is based on disk model of a file, because disks allow random access to any file block. A direct access file allows arbitrary blocks to be read or written. For example, a disk consisting of 256 blocks, the current position of read/write head is at 95th block. The block to be read or write is 250th block. Then we can access the 250th block directly without any restrictions. Another example for direct access is CD having 10 songs, at present we are listening the song no:3, suppose we want to listen the song no:9 then we can move from 3 to 9 without any restrictions.

Indexed Sequential File The main disadvantage in sequential file is that it takes more time to access a record. We can overcome this problem by using indexed sequential file. Records are organized in sequence based on a key field. For example, a file is consisting of 60,000 records, the master index divide the total records in to 6 blocks, each block consisting of a pointer to secondary index. The secondary index divide the 10,000 records into 10 indexes. Each index consisting of a pointer to its original location. Each record in the index file consisting of 2 fields. A key field and a pointer field. Suppose we want to access the 55,550th record, this pointer points to the 6th index in the secondary index. This index points to the original location of the record from 55,000 to 56,000.

Indexed Sequential File 0-1000 . 1000-2000 2000-3000 3000-4000 4000-5000 5000-6000 6000-7000 7000-8000 8000-9000 9000-10,000 0-10,000 . 10,000-20,000 20,000-30,000 30,000-40,000 40,000-50,000 50,000-60,000 50-51000 . 51000-52000 52000-53000 53000-54000 54000-55000 55000-56000 56000-57000 57000-58000 58000-59000 59000-10,000

File Directories The directory contains information about the files including attributes, locations and ownership. Sometimes the directories consisting of subdirectories also. The directory is itself a file, owned by the operating system and accessible by various file management routines. Sometimes the file system consisting of millions of files, at that situation it is very hard to manage the files. To manage these files grouped these files and load one group in to one partition. Each partition is called a directory. The directory can be viewed as a symbol table that translate filenames in to their directory entries. A directory structure provides a mechanism for organizing many files in the system.

Operations on the file directories Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system

Single Level Directory It is simplest of all directory structures. In this directory system having only one directory, it consisting of the all files. Sometimes it is said to be “Root Directory”. Advantage: Simple and Locate files quickly Issue: different users may accidentally use the same names for their files.

Two Level Directory The problem in single level directory is different users may be accidentally use the same names for their files. To avoid this problem, each user need a private directory. In this way, name chosen by one user don’t interfere with names chosen by different user and there is no problem caused by the same occurring in two or more directories.

Hierarchical structure directory The two level directory eliminates name conflicts among users but it is not satisfactory for users with a large number of files. To avoid this, creates the subdirectory and load the same type of files in to the subdirectory. So, in this method each can have as many directories are needed. This directory structure looks like tree, that’s why it is also called tree level directory structure.

Hierarchical structure directory If a reference is made to the file the current directory is searched. If a file is needed that is not in the current directory, then the user usually must either specify the path name or change the current directory To change directories system calls are provided which takes name as a parameter. Two types of path : absolute and relative An absolute path begins at the root and follows a path down to the specified file, giving the directory names on the path. A relative path name defines a path from the current directory.

Acyclic-Graph directory A shared directory or file will exist in the file system in two(or more) places at once. An acyclic graph—that is a graph with no cycles—allows directories to share sub directories and files. With a shared file, only one actual file exists, so any changes made by one person are immediately visible to the other.

Directory Implementation—Linear list Use linear list of names with pointers to the data blocks. To create a new file, we must first search the directory to be sure that no existing file has the same name. Then, we add a new entry at the end of the directory. To delete a file, we search the directory for the named file and then release the space allocated to it. To reuse the directory, we can attach it to the list of free directory entries. Disadvantages : It requires linear search, users will notice the slow speed while the pointer searches the whole list.

Directory Implementation—Hash Table Here the linear list store the directory entries but the hash table take the value computed from the file name and returns the pointer to the file name in the linear list. It decreases directory search time. Collisions – situations where two file names hash to the same location

File Allocation Methods Contagious allocation Linked Allocation Grouped allocation (or) indexed allocation

Contagious Method In this scheme, each file occupies a set of contagious blocks on the disk. This method is best suited for sequential files. The main problem in this is it is difficult to find the contagious free blocks in the disk. Another problem is external fragmentation, it means some free blocks could happen between two files.

Contagious Allocation

Linked Allocation Method Very easy to locate files because allocation is on an individual block basis. Each block contains a pointer to the next free block in the chain. A file allocation table consisting of a single entry for each file. Using this method, any free block can be added to a chain very easily. There is a link between one block to another block. So it is called linked allocation. Advantages: Avoid the external fragmentation Suited for sequential files. Disadvantages: The pointer itself occupies some memory with the block. It takes much accessing time.

Linked Allocation

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

Indexed Allocation Method In this method, the file allocation table contains a single entry for each file. The entry consisting of one index block, the block having the pointers to the other blocks which were occupied by the particular file. Advantages: Indexed allocation supports both sequential and direct access files, that’s why it is the most popular method. The file indexes are not physically stored as part of the file allocation table. Whenever the file size increases, we can easily add some more blocks to the index. No External Fragmentation.

Indexed Allocation

Free-Space Management Since the disk space is limited, we need to reuse the space from the deleted files for new files. To keep the track of free disk space, the system maintains a free-space list. The free-space list records all free disk blocks— those not allocated to some file or directory. To create a file, we search the free-space list for the required amount of space and allocate that space to the new file. This space is then removed from the free-space list. When a file is deleted, its disk space is added to the free-space list.

Free-Space Management Bit vector (n blocks) 1 2 n-1 … 0  block[i] free 1  block[i] occupied bit[i] =  Block number calculation (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 = 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

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

Linked Free Space List on Disk

Record Blocking For I/O to be performed, records must be organized as blocks. Blocking can be done by 3 ways: Fixed Blocking Variable Length spanned blocking Variable length un spanned blocking

Fixed Blocking In this method, records length are fixed. The prescribed number of records are stored in a block. For example, the block capacity is 100 records, but the number of records in the block is 90, then wasted space (100-90=10 records area) is called internal fragmentation. R2 R3 R4 R5 Track Gaps due to the hardware design Internal Fragmentation Internal Fragmentation

Variable length spanned Blocking In this method, records sizes are not same, variable length records are packed into blocks with no unused space. So, some records may divide into two blocks, at this type of situation a pointer is passed from the block to another block. Block 1 Block 2 R1 R2 R3 R4 R5 R6 Gaps due to hardware design

Variable length Unspanned Blocking In this method, records are variable length, but the records are not spanned between blocks. In this method, wasted area is serious problem, because of the inability to use the remainder of a block if the next record is larger than the remaining unused space. Gaps due to hardware design R1 R2 R3 R4 R5