Pengantar Organisasi Komputer - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Pengantar Organisasi Komputer

Description:

1. IKI20210. Pengantar Organisasi Komputer ... More information needs to be conveyed ... Needs to convey the identity of the device generating the interrupt ... – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 17
Provided by: bobbyn4
Category:

less

Transcript and Presenter's Notes

Title: Pengantar Organisasi Komputer


1
IKI20210Pengantar Organisasi KomputerKuliah No.
19 I/O, Interupsi
Sumber1. Hamacher. Computer Organization,
ed-4.2. Materi kuliah CS61C/2000 CS152/1997,
UCB.
20 November 2002 Bobby Nazief (nazief_at_cs.ui.ac.id)
Johny Moningka (moningka_at_cs.ui.ac.id) bahan
kuliah http//www.cs.ui.ac.id/iki20210/
2
What is the alternative to polling?
  • Wasteful to have processor spend most of its time
    spin-waiting for I/O to be ready
  • Wish we could have an unplanned procedure call
    that would be invoked only when I/O device is
    ready
  • Solution use interrupt mechanism to help I/O.
    Interrupt program when I/O ready, return when
    done with data transfer

3
I/O Interrupt
  • An I/O interrupt is like a subroutine call
    except
  • An I/O interrupt is asynchronous
  • More information needs to be conveyed
  • An I/O interrupt is asynchronous with respect to
    instruction execution
  • I/O interrupt is not associated with any
    instruction, but it can happen in the middle of
    any given instruction
  • I/O interrupt does not prevent any instruction
    from completion

4
Interrupt Driven Data Transfer
5
Instruction Set Support for I/O Interrupt
  • Save the PC for return
  • AVR uses the stacks
  • Where go when interrupt occurs?
  • AVR defines
  • Locations 0x000 0x002 for external interrupts
  • Locations 0x003 0x00C for internal interrupts
  • Determine cause of interrupt?
  • AVR uses vectored interrupt, which associates the
    location of the interrupt service routine (see
    above) with the device that causes it

6
Benefit of Interrupt-Driven I/O
  • 400 clock cycle overhead for each transfer,
    including interrupt. Find the of processor
    consumed if the hard disk is only active 5 of
    the time.
  • Interrupt rate polling rate
  • Disk Interrupts/sec 8 MB/s /16B 500K
    interrupts/sec
  • Disk Transfer Clocks/sec 500K 400
    200,000,000 clocks/sec
  • Processor for during transfer 250106/500106
    40
  • Disk active 5 ? 5 40 ? 2 busy
  • ?Determined by disks activity, whereas in
    Polling-driven I/O the Processor will be busy
    polling 40 of the time even if the disk is not
    active

7
Multiple Devices/Interrupts
  • Which I/O device caused exception?
  • Needs to convey the identity of the device
    generating the interrupt
  • Can avoid interrupts during the interrupt
    routine?
  • In general, interrupts are disabled whenever one
    is being serviced interrupts will be enabled
    after the service is completed
  • What if more important interrupt occurs while
    servicing this interrupt?
  • Who keeps track of status of all the devices,
    handle errors, know where to put/supply the I/O
    data?
  • In general, these is one of the tasks of
    Operating System

8
Device Identification
Device 1
Device N
Device 2
INTR1
INTR2
INTRn
CPU
wired-OR
  • The Interrupting Device may provide its identity
    through
  • Interrupt-Request (IRQ) bit in its Status
    Register, which will be evaluated one-by-one by
    the processor (polling)
  • Sending special code the the processor over the
    bus (vectored interrupt)

9
Prioritized Interrupt
Device 1
Device N
Device 2
INTR1
INTA1
CPU
  • An Interrupt Service Routine may be interrupted
    by other, higher-priority interrupt

10
Daisy Chain Scheme
Device 1 Highest Priority
Device N Lowest Priority
Device 2
INTA
Release
CPU
INTR
wired-OR
  • Advantage simple
  • Disadvantages
  • Cannot assure fairness A low-priority
    device may be locked out indefinitely

11
Exceptions
  • Interrupt is only a subset of Exception
  • Exception signal marking that something out of
    the ordinary has happened and needs to be
    handled
  • Interrupt asynchronous exception
  • Unrelated with instruction being executed
  • Trap synchronous exception
  • Related with instruction being executed
  • To recover from errors Illegal Instruction,
    Divide By Zero,
  • To debug a program
  • To provide privilege (for Operating System)

12
4 Responsibilities leading to OS
  • The I/O system is shared by multiple programs
    using the processor
  • Low-level control of I/O device is complex
    because requires managing a set of concurrent
    events and because requirements for correct
    device control are often very detailed
  • I/O systems often use interrupts to communicate
    information about I/O operations
  • Would like I/O services for all user programs
    under safe control

13
4 Functions OS must provide
  • OS guarantees that users program accesses only
    the portions of I/O device to which user has
    rights (e.g., file access)
  • OS provides abstractions for accessing devices by
    supplying routines that handle low-level device
    operations
  • OS handles the exceptions generated by I/O
    devices (and arithmetic exceptions generated by a
    program)
  • OS tries to provide equitable access to the
    shared I/O resources, as well as schedule
    accesses in order to enhance system performance

14
OS Interrupt Services
  • OSINIT Set interrupt vectors Time-slice clock
    ? SCHEDULER Trap ? OSSERVICES VDT interrupts
    ? IODATA
  • OSSERVICES Examine stack to determine requested
    operation Call appropriate routine
  • SCHEDULER Save current context Select a
    runnable process Restore saved context of new
    process Push new values for PS and PC on
    stack Return from interrupt

15
I/O ROUTINES DEVICE DRIVER
  • IOINIT Set process status to Blocked Initialize
    memory buffer address pointer Call device
    driver to initialize device enable interrupts
    in the device interface (VDTINIT) Return from
    subroutine
  • IODATA Poll devices to determine source of
    interrupt Call appropriate device driver
    (VDTDATA) If END 1, then set process status
    to Runnable Return from interrupt
  • VDTINIT Initialize device interface Enable
    interrupts Return from subroutine
  • VDTDATA Check device status If ready, then
    transfer character If character CR, then set
    END 1 else set END 0 Return from
    subroutine

16
Things to Remember
  • I/O gives computers their 5 senses
  • I/O speed range is million to one
  • Processor speed means must synchronize with I/O
    devices before use
  • Polling works, but expensive
  • processor repeatedly queries devices
  • Interrupts works, more complex
  • devices causes an exception, causing OS to run
    and deal with the device
  • I/O control leads to Operating Systems
Write a Comment
User Comments (0)
About PowerShow.com