File System Implementation - Operating Systems - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Operating Systems which includes File-System Structure, Defining, Logical File, Physical Device, Secondary, System Organized, File Control Block, Structure Consisting, Typical File Control Block etc.Key important points are: File System Implementation, File-System Structure, Defining, Logical File, Physical Device, Secondary, System Organized, File Control Block, Structure Consisting, Typical File Control Block

Typology: Slides

2012/2013

Uploaded on 03/28/2013

ekana
ekana 🇮🇳

4

(44)

370 documents

1 / 35

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
File System Implementation
Chapter 11
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download File System Implementation - Operating Systems - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

File System Implementation

Chapter 11

File-System Structure

  • A file system poses two distinct design problems - Defining how the file system should look to the user - Creating algorithms and data structures to map the logical file system onto the physical device
  • File system resides on secondary storage (disks)
  • File system organized into layers.
    • Each level uses the lower level to create new features for use by higher levels
  • File control block – storage structure consisting of information about a file

File-System Implementation

  • Several on-disk and in-memory structures are used

to implement a file system

  • On-disk structures
    • A boot control block
    • A partition control block (superblock)
    • A directory structure
    • file control blocks
  • In-memory structures
    • An in-memory partition table
    • An in-memory directory structure
    • The system-wide open-file table
    • The per-process open-file table

Creating a File

  • To create a new file the application program calls the logical

file system (which knows the format of the directory structures)

  • Allocates a new FCB
  • Reads the appropriate directory into memory
  • Updates the directory with new file name and FCB
  • Writes back to disk
  • Some operating systems (UNIX) treat a directory exactly as a

file, other operating systems (Windows), implement separate system calls for files and directories and treat directories separate from files.

In-Memory File System Structures

(a) refers to opening a file. (b) refers to reading a file.

Closing a File

  • After all I/O operations are complete a file should be

closed

  • The per-process table entry is removed and the system- wide entry’s open count is decremented
  • When all users that have opened the file close it, the updated file information is copied back to the disk-based directory structure and the system-wide open-file table entry is removed
  • Some systems Use a caching a scheme. All

information about an open file, except for its actual

data blocks, is in memory

Directory Implementation

  • Linear List
    • Uses a linear list of file names with pointers to data blocks, requires a linear search to find a particular entry
    • Simple to program but time-consuming to execute
  • Hash Table
    • Uses a linear list to stores directory entries but uses hashing to find the entry
    • Hashing can greatly decrease the directory search time
    • Handle collisions – situations where two file names hash to the same location
    • Major difficulties with a hash table are its fixed size and dependence on the hash function

Allocation Methods

  • An allocation method refers to how disk blocks are allocated

for files

  • Three major methods of allocating disk space are in wide use
    • Contiguous allocation
    • Linked allocation
    • Indexed allocation
  • Each method has its advantages and disadvantages
  • Some systems support all three but more commonly a system

will use one particular method

Contiguous Allocation of Disk Space

Contiguous Allocation (Cont.)

  • Contiguous allocation has some problems
    • Dynamic storage-allocation
      • How to satisfy a request of size n from a list of free blocks
    • External fragmentation
      • Free space is broken into chunks and the largest chunk is insufficient for a request
    • Determining how much space is needed for a file
      • Allocate too little and the file may not be extended
      • Allocate too much and space is wasted
    • File cannot grow

Linked Allocation

  • Solves all the problems of contiguous allocation
  • Each file is a linked list of disk blocks: blocks may be scattered

anywhere on the disk

  • The directory contains a pointer to the first and last blocks of

a file

block = pointer

Linked Allocation

File-Allocation Table

Indexed Allocation

  • Solves the external-fragmentation and size-declaration

problems of contiguous allocation

  • Supports direct access by bringing all the pointers together

into the index block

  • Each file has its own index block, which is an array of disk-

block addresses

index table