NETW 3005 - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

NETW 3005

Description:

NETW 3005 I/O Systems – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 39
Provided by: Compute346
Category:
Tags: netw | interface

less

Transcript and Presenter's Notes

Title: NETW 3005


1
NETW 3005
  • I/O Systems

2
Reading
  • For this lecture, you should have read Chapter 13
    (Sections 1-4, 7).

3
This Lecture I/O systems
  • Hardware ports, buses, controllers
  • Application I/O interface
  • Kernel I/O services.

4
Central issues
  • How are I/O commands actually implemented?
  • How does the O/S manage the wide range of I/O
    devices that are available?
  • Disks, CD/DVD drives, tapes
  • Modems, network cards
  • Screens, keyboards, mice, joysticks

5
What is a Device Driver? Each device has its own
set of specialized commands that only its driver
knows. A device driver is a system program that
converts the system calls of the operating system
into device specific commands . printers, video
adapters, network cards, sound cards A device
that controls the transfer of data from a
computer to a peripheral device and vice versa.
Example Graphics controller SCSI ( Small
Computer system Interface) Controller IDE (
Integrated Drive Electronics) Controller-
6
(No Transcript)
7
I/O Hardware some background
  • An I/O device is linked to a machine via a port.
  • The link is normally a set of wires called a bus.
  • At the end of the link, theres a device
    controller, (basically, a processor.)
  • A signal on a bus is basically a temporal
    sequence of voltages for each wire.

8
I/O Hardware
bus
I/O device
device controller
CPU
port
9
The PCI bus
CPU
monitor
cache
graphics controller
memory/controller
SCSI bus
memory
PCI bus
IDE disc controller
expansion bus interface
keyboard
disc
disc
parallel port
serial port
disc
disc
10
Device controller registers
  • How does the CPU give commands to a device via a
    bus?
  • A device controller has a number of registers for
    holding signals.
  • The CPU can effectively write to and read from
    these.
  • Some registers hold data some hold control
    signals.

11
Device controller registers
  • How can the CPU specify which device its giving
    commands to?
  • Each different port in the system has an address
    range.
  • The CPU can issue I/O instructions to particular
    addresses.

12
Device I/O Port Locations on PCs (partial)
13
Some example controller registers
  • A controller might have the following registers
  • data-out contains a byte of data.
  • status contains a busy bit (indicating the
    controllers state).
  • command contains a command-ready bit (indicating
    CPU has sent some data) and a write bit
    (indicating direction of data flow).

14
Programmed I/O and handshaking
  • For each byte to be transferred to device
  • The CPU reads the busy bit until it is clear.
  • The CPU sets the write bit and writes a byte to
    the data-out register.
  • The CPU sets the command-ready bit

set means bit value will become 1
clear means bit value will become 0
15
Programmed I/O and handshaking
  1. The controller reads the command-ready bit until
    it is set. Then it sets the busy bit.
  2. The controller reads the write command from the
    command register and then copies the data-out
    register to the device.
  3. The controller clears the command-ready bit and
    then the busy bit.

16
Polling and its Problems
  • The step where the CPU cycles waiting for the
    busy bit to be clear is known as polling or busy
    waiting.
  • If the CPU is polling, then its wastes CPU time.
  • An alternative to polling is interrupts.

17
Interrupts
  • The CPU hardware contains a wire called the
    interrupt request line.
  • The CPU tests this line after each instruction it
    executes.
  • If a signal is detected, the CPU saves its
    current state and transfers control to interrupt
    handler .
  • Interrupt handler process the interrupt and
    transfers the control to the CPU.
  • If devices uses interrupt to communicate, then
    CPU doesn't need to poll.

18
Types of interrupt
  • Errors (exceptions)
  • divide by zero, invalid memory access,
  • Device-generated interrupts
  • device has read a byte modem buffer full.
  • Software interrupts (traps)
  • system call, context switch
  • Some of these are more urgent than others.

19
Interrupt priority levels
  • One way of dealing with differing degrees of
    urgency is to provide two interrupt request
    lines
  • maskable interrupts device-generated interrupts
    and traps. These can be disabled.
  • nonmaskable interrupts for signalling error
    messages. Never disabled.

20
Direct Memory Access
  • Programmed I/O (sending data byte-by-byte to a
    device) is laborious.
  • For large chunks of data, direct memory access
    (DMA) is used.
  • A DMA controller is a kind of processor that
    transfers data between I/O devices and memory
    without involving main processor (CPU)

21
Direct Memory Access
  • DMA operation needs the
  • channel number (which I/O device requires the
    DMA),
  • a beginning address in memory for the transfer,
  • the number of bytes to transfer, and
  • the direction of transfer (I/O to memory, or
    vice-versa)
  • The processor starts the DMA activity with an
    ordinary I/O write to a control register in the
    DMA controller, then continues its work as usual
  • When DMA activity is finished, DMA controller
    interrupts the processor

22
What is a Device Driver? Each device has its own
set of specialized commands that only its driver
knows. A device driver is a system program that
converts the system calls of the operating system
into device specific commands . printers, video
adapters, network cards, sound cards A device
that controls the transfer of data from a
computer to a peripheral device and vice versa.
Example Graphics controller SCSI ( Small
Computer system Interface) Controller IDE (
Integrated Drive Electronics) Controller-
23
The kernel-device interface
  • How does the O/S manage the huge range of
    possible I/O devices?
  • Clearly, we dont want to rewrite the kernel
    every time we add a new device.
  • We therefore need to impose a standard interface
    protocol on devices.

24
The kernel-device interface
  • The method for doing this is to encapsulate
    device-specific information in special kernel
    modules called device drivers.
  • These device drivers translate system calls into
    device-specific commands.

25
Device drivers and controllers
  • Theres a one-to-one mapping between device
    drivers and device controllers.
  • Device drivers are software.
  • Device controllers are hardware.

26
Types of I/O device
  • I/O devices vary widely, along several
    dimensions.
  • Character stream versus block.
  • Sequential versus random access.
  • Synchronous versus asynchronous.
  • Shareable versus dedicated.
  • OSs work with a small set of device types which
    can execute a standard set of commands.

27
Character devices character devices relate to
devices through which the system transmits data
one character at a time. (Get and
Put) Example Key boards serial modem
28
Block devices
  • Block devices correspond to devices through
    which the system moves data in the form of
    blocks.
  • Example addressable devices
  • hard disks, CD-ROM drives, or
    memory-regions.
  • The standard commands necessary for a block
    device are
  • Read block,
  • Write block,
  • Seek block (for random-access block devices).

29
Network devices, e.g. sockets
A socket is one endpoint of a two-way
communication link between two programs running
on the network.
  • The standard commands for a socket
  • Create socket
  • Connect local socket to remote socket
  • Listen for remote applications to local socket
  • Send information to a socket
  • Receive information from a socket
  • Select monitors a set of sockets.

30
Ip addressport Of client
Ip addressport Of server
00000111110000 0000001111111
client
server
socket
31
Blocking and nonblocking I/O
  • Theres an important distinction between blocking
    and nonblocking I/O system calls.
  • If a process issues a blocking I/O system call,
    it waits until the I/O is completed.
  • If a process issues a nonblocking I/O call, it
    waits for a fixed interval, and then returns.
  • If a process issues an asynchronous I/O call, the
    I/O operation occurs in full, but the process
    doesnt wait for it.

32
Differences?
  • In nonblocking I/O, you know how long the I/O is
    going to take, but you dont know if all the data
    will be transferred.
  • In asynchronous I/O, you know all the data will
    be transferred but you dont know how long it
    will take, so you dont know where youll be in
    your program when it comes back.

33
Examples?
  • Blocking I/O
  • disk reads. (The standard situation.)
  • Non-blocking I/O
  • reads from a mouse, joystick, real-time video.
  • Asynchronous I/O
  • printing something.

34
Kernel I/O services
  • So far, we have demonstrated the use of device
    drivers for the kernel.
  • But we havent really explained why there should
    be an I/O subsystem.
  • Why not just interface straight to the device
    drivers?

35
Kernel I/O services
  • In fact, there are several services performed by
    the I/O subsystem before the device drivers are
    called.
  • I/O Scheduling,
  • I/O Buffering,
  • Spooling.

36
I/O scheduling
  • At any one time, there might be several requests
    for I/O waiting to be serviced.
  • We could just do these in first-come-first-served
    order.
  • Disadvantages with this scheme?
  • Lets say the disk arm is currently near the
    beginning of a disk, and there are 5 I/O
    requests 3 for places near the beginning and 2
    for places near the end.

37
I/O buffering
  • A buffer is used to provide communication between
    two processes with different speeds.
  • In the consumer/producer problem, assume that the
    consumer process is faster than the producer
    process.
  • Producer fills up the buffer, switches to a
    second buffer and signals the consumer
  • Consumer reads full buffer, then waits.

38
Spooling
  • A spool is a buffer that holds output for a
    device that cannot accept interleaved data
    streams - e.g. a printer.
  • Rather than sending data straight to the printer,
    the O/S stores the data in buffers.
  • The printer can then process the output from one
    buffer at a time.
Write a Comment
User Comments (0)
About PowerShow.com