File-System Interface - PowerPoint PPT Presentation

About This Presentation
Title:

File-System Interface

Description:

Title: Figure 11.01 Author: Marilyn Turnamian Last modified by: Faizan Rehman Created Date: 8/24/1999 1:56:22 PM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 56
Provided by: Maril108
Category:

less

Transcript and Presenter's Notes

Title: File-System Interface


1
File-System Interface Implementation
Final-4
2
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.
  • Time, date, and user identification data for
    protection, security, and usage monitoring.
  • Information about files are kept in the directory
    structure, which is maintained on the disk.

3
File Operations
  • Create
  • Write
  • Read
  • Reposition within file file seek
  • Delete
  • Truncate
  • Open(Fi) search the directory structure on disk
    for entry Fi, and move the content of entry to
    memory.
  • Close (Fi) move the content of entry Fi in
    memory to directory structure on disk.

4
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

5
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)

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

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

8
Protection
  • File owner/creator should be able to control
  • what can be done
  • by whom
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

9
Access Lists and Groups
  • Mode of access read, write, execute
  • Three classes of users
  • RWX
  • a) owner access 7 ? 1 1 1 RWX
  • b) group access 6 ? 1 1 0
  • RWX
  • c) public access 1 ? 0 0 1
  • Ask manager to create a group (unique name), say
    G, and add some users to the group.
  • For a particular file (say game) or subdirectory,
    define an appropriate access.

owner
group
public
chmod
761
game
Attach a group to a file chgrp G
game
10
File-System Structure
  • File structure
  • Logical storage unit
  • 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.

11
Layered File System
12
File System Implementation
  • File systems store several important data
    structures on the disk
  • A boot-control block, ( per volume ) a.k.a.
    the boot block in UNIX or the partition boot
    sector in Windows contains information about how
    to boot the system. This will generally be the
    first sector of the volume if there is a bootable
    system loaded on that volume, or vacant
    otherwise.
  • A volume control block, ( per volume ) a.k.a.
    the master file table in UNIX or
    the superblock in Windows, which contains
    information such as the partition table, number
    of blocks on each filesystem, and pointers to
    free blocks and free FCB blocks.
  • A directory structure ( per file system ),
    containing file names and pointers to
    corresponding FCBs. UNIX uses inode numbers, and
    NTFS uses a master file table.
  • The File Control Block, FCB, ( per file )
    containing details about ownership, size,
    permissions, dates, etc. UNIX stores this
    information in inodes, and NTFS in the master
    file table as a relational database structure.

13
A Typical File Control Block
14
Directory Implementation
  • Linear list of file names with pointer to the
    data blocks.
  • simple to program
  • time-consuming to execute
  • Hash Table linear list with hash data
    structure.
  • decreases directory search time
  • collisions situations where two file names hash
    to the same location
  • fixed size

15
Allocation Methods
  • An allocation method refers to how disk blocks
    are allocated for files
  • Contiguous allocation
  • Linked allocation
  • Indexed allocation

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

17
Contiguous Allocation of Disk Space
18
Linked Allocation
  • Each file is a linked list of disk blocks blocks
    may be scattered anywhere on the disk.

19
Linked Allocation (Cont.)
  • Simple need only starting address
  • Free-space management system no waste of space
  • No random access
  • Mapping

20
Linked Allocation
21
Indexed Allocation
  • Brings all pointers together into the index
    block.
  • Logical view.

index table
22
Example of Indexed Allocation
23
Indexed Allocation (Cont.)
  • Need index table
  • Random access
  • Dynamic access without external fragmentation,
    but have overhead of index block.
  • 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.

24
Linked Free Space List on Disk
25
Disk
Final-4
26
Disk Structure
  • Disk drives are addressed as large 1-dimensional
    arrays of logical blocks, where the logical block
    is the smallest unit of transfer.
  • The 1-dimensional array of logical blocks is
    mapped into the sectors of the disk sequentially.
  • Sector 0 is the first sector of the first track
    on the outermost cylinder.
  • Mapping proceeds in order through that track,
    then the rest of the tracks in that cylinder, and
    then through the rest of the cylinders from
    outermost to innermost.

27
Disk Structure
28
Disk Scheduling
  • The operating system is responsible for using
    hardware efficiently for the disk drives, this
    means having a fast access time and disk
    bandwidth.
  • Access time has two major components
  • Seek time is the time for the disk are to move
    the heads to the cylinder containing the desired
    sector.
  • Rotational latency is the additional time waiting
    for the disk to rotate the desired sector to the
    disk head.
  • Minimize seek time
  • Seek time ? seek distance
  • Disk bandwidth is the total number of bytes
    transferred, divided by the total time between
    the first request for service and the completion
    of the last transfer.

29
Disk Scheduling (Cont.)
  • Several algorithms exist to schedule the
    servicing of disk I/O requests.
  • We illustrate them with a request queue (0-199).
  • 98, 183, 37, 122, 14, 124, 65, 67
  • Head pointer 53

30
FCFS
Illustration shows total head movement of 640
cylinders.
31
SSTF
  • Selects the request with the minimum seek time
    from the current head position.
  • SSTF scheduling is a form of SJF scheduling may
    cause starvation of some requests.
  • Illustration shows total head movement of 236
    cylinders.

32
SSTF (Cont.)
33
SCAN
  • The disk arm starts at one end of the disk, and
    moves toward the other end, servicing requests
    until it gets to the other end of the disk, where
    the head movement is reversed and servicing
    continues.
  • Sometimes called the elevator algorithm.
  • Illustration shows total head movement of 208
    cylinders.

34
SCAN (Cont.)
35
C-SCAN
  • Provides a more uniform wait time than SCAN.
  • The head moves from one end of the disk to the
    other. servicing requests as it goes. When it
    reaches the other end, however, it immediately
    returns to the beginning of the disk, without
    servicing any requests on the return trip.
  • Treats the cylinders as a circular list that
    wraps around from the last cylinder to the first
    one.

36
C-SCAN (Cont.)
37
C-LOOK
  • Version of C-SCAN
  • Arm only goes as far as the last request in each
    direction, then reverses direction immediately,
    without first going all the way to the end of the
    disk.

38
C-LOOK (Cont.)
39
RAID (redundant array of independent disks)
Structure
  • RAID multiple disk drives provides reliability
    via redundancy.
  • RAID is arranged into six different levels.

40
RAID (cont)
  • Several improvements in disk-use techniques
    involve the use of multiple disks working
    cooperatively.
  • Disk striping uses a group of disks as one
    storage unit.
  • RAID schemes improve performance and improve the
    reliability of the storage system by storing
    redundant data.
  • Mirroring or shadowing keeps duplicate of each
    disk.
  • Block interleaved parity uses much less
    redundancy.

41
Standard levels
  • RAID 0 comprises striping (but no parity or
    mirroring).
  • RAID 1 comprises mirroring (without parity or
    striping).
  • RAID 2 comprises bit-level striping with
    dedicated Hamming-code parity.
  • RAID 3 comprises byte-level striping with
    dedicated parity.
  • RAID 4 comprises block-level striping with
    dedicated parity.
  • RAID 5 comprises block-level striping with
    distributed parity.
  • RAID 6 comprises block-level striping with double
    distributed parity.

42
RAID Levels
43
RAID (0 1) and (1 0)
44
Disk Attachment
  • Disks may be attached one of two ways
  • Host attached via an I/O port
  • Network attached via a network connection

45
I/O
Final-4
46
A Typical PC Bus Structure
47
Interrupts
  • CPU Interrupt request line triggered by I/O
    device
  • Interrupt handler receives interrupts
  • Maskable to ignore or delay some interrupts
  • Interrupt vector to dispatch interrupt to correct
    handler
  • Based on priority
  • Some unmaskable
  • Interrupt mechanism also used for exceptions

48
Interrupt-Driven I/O Cycle
49
Intel Pentium Processor Event-Vector Table
50
Direct Memory Access
  • Used to avoid programmed I/O for large data
    movement
  • Requires DMA controller
  • Bypasses CPU to transfer data directly between
    I/O device and memory

51
Six Step Process to Perform DMA Transfer
52
Characteristics of I/O Devices
53
Blocking and Nonblocking I/O
  • Blocking - process suspended until I/O completed
  • Easy to use and understand
  • Insufficient for some needs
  • Nonblocking - I/O call returns as much as
    available
  • User interface, data copy (buffered I/O)
  • Implemented via multi-threading
  • Returns quickly with count of bytes read or
    written
  • Asynchronous - process runs while I/O executes
  • Difficult to use
  • I/O subsystem signals process when I/O completed

54
Kernel I/O Subsystem
  • Scheduling
  • Some I/O request ordering via per-device queue
  • Some OSs try fairness
  • Buffering - store data in memory while
    transferring between devices
  • To cope with device speed mismatch
  • To cope with device transfer size mismatch
  • To maintain copy semantics

55
Kernel I/O Subsystem
  • Caching - fast memory holding copy of data
  • Always just a copy
  • Key to performance
  • Spooling - hold output for a device
  • If device can serve only one request at a time
  • i.e., Printing
  • Device reservation - provides exclusive access to
    a device
  • System calls for allocation and deallocation
  • Watch out for deadlock
Write a Comment
User Comments (0)
About PowerShow.com