1

 

 

UNIT 2/LECTURE 1

File-System Interface

 

•          File Concept

•          Access :Methods

•          Directory Structure

•          Protection

•          Consistency Semantics

 

File Concept

 

•          Contiguous logical address space

•          Types:

–         Data

                                                        I.            numeric

                                                      II.            character

                                                   III.            binary

–         Program

 

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.

 

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.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

File Types – name, extension

 

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

 

Directory Structure

 

•          A collection of nodes containing information about all files.

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)

 

Operations Performed on Directory

 

•          Search for a file

•          Create a file

•          Delete a file

•          List a directory

•          Rename a file

•          Traverse the file system

 

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 Pascal programs, all games, …)

 

Single-Level Directory

 

•          A single directory for all users.

 

 

•          Naming problem

•          Grouping problem

 

Two-Level Directory

 

Separate directory for each user

 

•          Path name

•          Can have the saem file name for different user

•          Efficient searching

•          No grouping capability

 

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

Q1.

Discuss various File access methods.

Dec, 2011, June 2011

10

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

371-387

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 2

Tree-Structured Directories

 

 

•          Efficient searching

•          Grouping Capability

•          Current directory (working directory)

–         cd /spell/mail/prog

–         type list

•          Absolute or relative path name

•          Creating a new file is done in current directory.

•          Delete a file

                        rm <file-name>

•          Creating a new subdirectory is done in current directory.

                        mkdir <dir-name>

            Example:  if in current directory   /spell/mail

                        mkdir count

 

 

•          Deleting “mail” ή deleting the entire subtree rooted by “mail”.

 

Acyclic-Graph Directories

 

•          Have shared subdirectories and files.

 

 

•          Two different names (aliasing)

•          If dict deletes list ή dangling pointer.

            Solutions:

–         Backpointers, so we can delete all pointers.
Variable size records a problem.

–         Backpointers using a daisy chain organization.

–         Entry-hold-count solution.

 

General Graph Directory

 

 

•          How do we guarantee no cycles?

–         Allow only links to file not subdirectories.

–         Garbage collection.

–         Every time a new link is added use a cycle detection
algorithm to determine whether it is OK.

 

Protection

 

•          File owner/creator should be able to control:

–         what can be done

–         by whom

•          Types of access

–         Read

–         Write

–         Execute

–         Append

–         Delete

–         List

 

Access Lists and Groups

 

 

 

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

387-392

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 3

File-System Implementation

 

•          File-System Structure

•          Allocation Methods

•          Free-Space Management

•          Directory Implementation

•          Efficiency and Performance

•          Recovery

 

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

 

Layered File System

 

 

A Typical File Control Block

 

 

 

 

 

 

In-Memory File System Structures

 

·         The following figure illustrates the necessary file system structures provided by the operating systems.

 

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

 

 

Directory Implementation

 

  • Linear list of file names with pointer to the data blocks.
    1. simple to program
    2. time-consuming to execute
  • Hash Table – linear list with hash data structure.

                                I.            decreases directory search time

                              II.            collisions – situations where two file names hash to the same location

                           III.            fixed size

 

Allocation Methods

 

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

 

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

 

  • Mapping from logical to physical

 

 

Block to be accessed = ! + starting address

Displacement into block = R

 

Contiguous Allocation of Disk Space

 

 

Extent-Based Systems

 

  • Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation scheme
  • Extent-based file systems allocate disk blocks in extents
  • An extent is a contiguous block of disks

                                I.            Extents are allocated for file allocation

                              II.            A file consists of one or more extents.

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

411-424

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 4

Linked Allocation

 

  • Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.

 

 

  • Simple – need only starting address
  • Free-space management system – no waste of space
  • No random access
  • Mapping

 

 

Block to be accessed is the Qth block in the linked chain of blocks representing the file.

Displacement into block = R + 1

File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2.

 

 

 

 

 

 

 

File-Allocation Table

 

 

Indexed Allocation

 

  • Brings all pointers together into the index block.
  • Logical view.

 

 

 

  • 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.

 

 

Q = displacement into index table

R = displacement into block

 

Indexed Allocation – Mapping

 

  • Mapping from logical to physical in a file of unbounded length (block size of 512 words).
  • Linked scheme – Link blocks of index table (no limit on size).

 

 

Combined Scheme:  UNIX (4K bytes per block)

 

 

 

 

 

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

424-429

 

 

UNIT 2/LECTURE 5

Free-Space Management

 

 

 

  • 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

  • Need to protect:

a.       Pointer to free list

b.       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

c.       Solution:

Ψ  Set bit[i] = 1 in disk

Ψ  Allocate block[i]

Ψ  Set bit[i] = 1 in memory

 

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

o   decreases directory search time

o   collisions – situations where two file names hash to the same location

o   fixed size

 

Linked Free Space List on Disk

 

 

 

Overview of Mass Storage Structure

 

  • Magnetic disks provide bulk of secondary storage of modern computers
    • Drives rotate at 60 to 200 times per second
    • Transfer rate is rate at which data flow between drive and computer
    • Positioning time (random-access time) is time to move disk arm to desired cylinder (seek time) and time for desired sector to rotate under the disk head (rotational latency)
    • Head crash results from disk head making contact with the disk surface
  • Disks can be removable
  • Drive attached to computer via I/O bus

o   Busses vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI

o   Host controller in computer uses bus to talk to disk controller built into drive or storage array

 

Moving-head Disk Machanism

 

 

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.

o   Sector 0 is the first sector of the first track on the outermost cylinder.

o   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.

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

430-437

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 6

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.
  • 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

 

FCFS

 

Illustration shows total head movement of 640 cylinders.

 

 

 

 

 

 

 

 

 

 

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.

 

 

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.

 

 

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.

 

 

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.

 

Selecting a Disk-Scheduling Algorithm

 

  • SSTF is common and has a natural appeal
  • SCAN and C-SCAN perform better for systems that place a heavy load on the disk.
  • Performance depends on the number and types of requests.
  • Requests for disk service can be influenced by the file-allocation method.
  • The disk-scheduling algorithm should be written as a separate module of the operating system, allowing it to be replaced with a different algorithm if necessary.
  • Either SSTF or LOOK is a reasonable choice for the default algorithm.

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

Q1.

Suppose that a disk has 500 cylinders. The drive is currently serving a request at cylinder 143 and the previous request was at cylinder 125. The queue of pending request in FIFO orders is 80, 1470, 913, 1774, 948, 1509, 1022, 1750 and 130. What is the total distance that the disk arm moves for the following algorithms? (I) FCFS (II) SSTF (III) LOOK (IV) C-SCAN

Dec, 2011

10

 

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

491-498

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 7

I/O Systems

 

  • I/O Hardware
  • Application I/O Interface
  • Kernel I/O Subsystem
  • Transforming I/O Requests to Hardware Operations

 

Objectives

 

  • Explore the structure of an operating system’s I/O subsystem
  • Discuss the principles of I/O hardware and its complexity
  • Provide details of the performance aspects of I/O hardware and software

 

I/O Hardware

 

  • Incredible variety of I/O devices
  • Common concepts
    • Port
    • Bus (daisy chain or shared direct access)
    • Controller (host adapter)
  • I/O instructions control devices
  • Devices have addresses, used by

·         Direct I/O instructions

·         Memory-mapped I/O

 

 

A Typical PC Bus Structure

 

 

Polling

·         Determines state of device

o   command-ready

o   busy

o   Error

·         Busy-wait cycle to wait for I/O from device

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

o   Based on priority

o   Some nonmaskable

·         Interrupt mechanism also used for exceptions

 

Interrupt-Driven I/O Cycle

 

 

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Six Step Process to Perform DMA Transfer

 

 

Application I/O Interface

 

  • I/O system calls encapsulate device behaviors in generic classes
  • Device-driver layer hides differences among I/O controllers from kernel
  • Devices vary in many dimensions

                                I.            Character-stream or block

                              II.            Sequential or random-access

                           III.            Sharable or dedicated

                           IV.            Speed of operation

                             V.            read-write, read only, or write only

 

A Kernel I/O Structure

 

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

 

 

 

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

456-469

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 8

Characteristics of I/O Devices

 

 

Block and Character Devices

 

  • Block devices include disk drives
    • Commands include read, write, seek
    • Raw I/O or file-system access
    • Memory-mapped file access possible
  • Character devices include keyboards, mice, serial ports

o   Commands include get, put

o   Libraries layered on top allow line editing

 

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

o   Difficult to use

o   I/O subsystem signals process when I/O completed

 

 

 

 

 

 

 

 

 

 

 

 

 

Two I/O Methods

 

                                             Synchronous                                          Asynchronous

 

Device-status Table

 

 

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

 

 

Error Handling

 

  • OS can recover from disk read, device unavailable, transient write failures
  • Most return an error number or code when I/O request fails
  • System error logs hold problem reports

 

S.NO

RGPV QUESTION

YEAR

MARKS

 

Write short note on I/O buffering and Kernal I/O subsystem.

June -11

10

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

466-473

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

UNIT 2/LECTURE 9

I/O Protection

 

  • User process may accidentally or purposefully attempt to disrupt normal operation via illegal I/O instructions

o   All I/O instructions defined to be privileged

o   I/O must be performed via system calls

4  Memory-mapped and I/O port memory locations must be protected too

 

Use of a System Call to Perform I/O

 

 

Kernel Data Structures

 

  • Kernel keeps state info for I/O components, including open file tables, network connections, character device state
  • Many, many complex data structures to track buffers, memory allocation, “dirty” blocks
  • Some use object-oriented methods and message passing to implement I/O

 

I/O Requests to Hardware Operations

 

  • Consider reading a file from disk for a process:
     

o   Determine device holding file

o   Translate name to device representation

o   Physically read data from disk into buffer

o   Make data available to requesting process

o   Return control to process

 

 

 

 

 

 

 

 

Life Cycle of An I/O Request

 

 

 

 

S.NO

RGPV QUESTION

YEAR

MARKS

1

Write short note on Interrupt & Service Routine

June 11

10

 

 

 

 

 

 

REFERNCES

S.NO

BOOK  NAME

AUTHORS

Edition

PAGE NO

  1

   OPERATING  SYSTEM  CONCEPT

Peter Bare Galvin, Abraham Silberschatz

SIXTH

44-48

 

 

 

 

 

Back To Home