CSCI2402 Operating Systems and Computer Networks - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

CSCI2402 Operating Systems and Computer Networks

Description:

Providing a simple and consistent interface for users. Speed of transfer ... direction is up and the arm is at sector 1 when a sectior 0 request arrives, the ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 24
Provided by: bki9
Category:

less

Transcript and Presenter's Notes

Title: CSCI2402 Operating Systems and Computer Networks


1
CSCI2402 Operating Systems and Computer Networks
  • Logical I/O

2
Logical I/O
  • Managing the transfer of data to/from I/O devices
  • Issues
  • Range of different devices
  • Complexity of operation
  • Providing a simple and consistent interface for
    users
  • Speed of transfer
  • Speed disparity between CPU and mechanical
    devices
  • Efficiency

3
Logical I/O
  • Objectives
  • Create a system which provides
  • Device independence
  • Simple, uniform file/device naming and access
  • Efficiency max. CPU time running processes
  • operate I/O device at max poss. speed

4
The Disk Surface
  • The surface of a disk is logically divided into
    concentric circular tracks
  • 1,000s are now common
  • The surface is also divided into segments
  • a track through a particular segment is a sector
  • note often the term sector is confusingly used
    to refer to both segments and sectors!
  • on typical PC disks, each sectorholds 512 bytes

5
Layers of a typical I/O system
user processes
  • Device Independent
  • Naming files
  • Naming devices
  • Device protection
  • Buffering
  • Device Dependent
  • Maps logical requests into hardware operations.
  • Error reporting
  • Performs the op. and uses interrupts to signal
    successful read or write ops.

Device Driver
6
Logical I/O
  • The User View (User Process)
  • User sees a logical device and a standard
    interface
  • Program I/O instructions translated into system
    calls to invoke OS functions
  • Some I/O instructions provided by libraries
    linked to user programs
  • Printing tasks often carried out via Spooling
  • Spooling Directory Daemons

7
Logical I/O
  • 2. The Device Independent Layer (I/O Control
    System)
  • Provides a uniform logical interface to users
    which is device-independent
  • Provides a logical file/device naming system to
    the user
  • Implements any file/device protection strategy
  • Provides info. about file sizes etc. but hides
    precise physical details
  • Applies any buffering techniques to increase
    efficiency

8
Buffering
  • Buffering
  • Without Buffering

OS
User Process
Is this efficient ?
9
Buffering
  • b) With Single Buffering

OS
User Process
Buffer
10
Buffering
  • c) With Double Buffering

OS
User Process
Buffer B
Buffer A
11
Device Driver
  • 3. The Device Driver (device-dependent)
  • When it receives a logical request for e.g. a
    file on disk, it must
  • Figure out where the file is on the disk
  • Check to see if the drive motor is running
  • Determine if the arm is positioned over the
    correct sector
  • etc. etc. etc.
  • i.e. Decide which device hardware operations are
    necessary and in which sequence.

12
Device Driver
  • then give appropriate commands to hardware.
  • Then if OK (and relevant!)
  • Pass data back to I/O Control System
  • Or if not OK
  • Try and correct (e.g. retry, ignore etc.) or pass
    back an error report)

13
Disk Scheduling Algorithms
14
Disk Scheduling Concepts
  • The operating system is generally responsible for
    using the hardware efficiently
  • Whenever a process needs I/O to or from a disk,
    it issues a system call to the operating system
  • the system call request specifies
  • whether the operation is input or output
  • what the disk address for the operation is
  • what the memory address of the transfer is
  • the number of bytes to be transferred
  • The OS maps block numbers into head and sector
    physical addresses
  • If the drive (and its controller) are free, the
    request can be serviced immediately
  • if not, the request will have to wait in a
    pending queue

15
Performance Parameters
  • To the operating system a disk drive can be
    characterised in terms of performance parameters
  • the transfer rate
  • the rate at which data flow between the drive and
    computer
  • measured (now) in Mb per second
  • e.g. 33 Mb/s or 66 Mb/s typical for modern PC
    drives
  • the seek time
  • time to move the disk arm to the required sector
  • e.g. 9 ms average seek time

16
First-Come, First-Served
  • As in process scheduling, the simplest algorithm
    is to keep a queue of all pending requests and
    service them in the order they joined the queue
  • this is (again) called first-come, first-served
    (FCFS)

17
FCFS Example
  • Consider a queue, for a disk with 200 sectors,
    with requests for I/O to blocks on sectors
  • 98, 183, 37, 122, 14, 124, 65, 67
  • the disk heads are initially positioned at
    cylinder 53
  • a total head movement of 640 sectors has occurred

18
Shortest-Seek(-Time)-First
  • The shortest-seek-first (or shortest-seek-time-fir
    st) algorithm improves the FCFS situation by
    trying to reduce the head movement distance by
    sorting the pending I/O requests according to
    closeness
  • on a hard disk the seek time is proportional to
    distance
  • For each block, the pending queue is examined
  • the nearest block in the queue is serviced next
  • Note that this algorithm is similar to SJF
  • it too may result in starvation
  • if near blocks join the queue then blocks that
    are far away will never get serviced
    (particularly if the disk is busy)

19
SS(-T-)F Example
  • The same queue as for FCFS
  • 98, 183, 37, 122, 14, 124, 65, 67
  • the disk heads are initially positioned at sector
    53
  • the total head movement has been reduced to 236

20
Elevator Algorithm
  • The disk arm starts moving in one direction
  • it continues in the current direction, servicing
    all pending requests as it passes over them
  • when it gets to the last pending request in the
    direction it is going, it reverses direction and
    services all the pending requests
  • this is the same as the algorithm used in most
    elevators (lifts)
  • This improves FCFS without suffering starvation
  • middle blocks are favoured if the disk is heavily
    used
  • if the direction is up and the arm is at sector 1
    when a sectior 0 request arrives, the block must
    wait until all blocks are serviced upwards, and
    again downwards, before its turn

21
Elevator Example
  • The same I/O request queue again
  • 98, 183, 37, 122, 14, 124, 65, 67 heads at 53
  • the initial direction is DOWN
  • the total head movement has been reduced to 208

22
Selecting an Algorithm
  • Which is the best algorithm to use?
  • SSF is common in practice as it usually performs
    slightly better than the elevator algorithm (on
    lightly loaded systems)
  • the elevator algorithm is a good candidate for
    general purpose as it performs well without
    starvation
  • The choice of disk arm scheduling algorithm may
    well be influenced by the file allocation method
  • contiguous allocation ? many short head movements

23
Logical I/O
  • Summary

Make an I.O call
Naming, Protection, Blocking, Buffering
Map logical requests into hardware ops
Wake up driver when I/O completed
Perform I/O operation
Write a Comment
User Comments (0)
About PowerShow.com