Title: CS220 Computer Organization
1CS220 Computer Organization
- Chapter 13 Input and Output
2CS220 Computer OrganizationInput and Output
- A brief history of User Interfaces (not from
text) - Wires and plugs ENIAC rebuilt the computer
by reconnecting the components - Batch mode punched cards, operator
controlling of jobs - Input punching cards on a typewriter like
machine - Output printout given back to you by the
operator - Timesharing late 1960s One CPU is shared
among multiple users I/O slow so user had
illusion of control of the machine - Input TTY (type in program), keyboards came
later - Output TTY (results typed out), VDT came later
(video display terminal) - GUI early 1970s Xerox Corp. Used GUI
internally - Steve Jobs visited Xerox and took the ideas of
Xerox and a number of Xerox employees and
introduced the Apple Macintosh in 1984
considered the first commercially available GUI
machine
3CS220 Computer OrganizationInput and Output
- Input and Output
- Input and output devices vary in purpose, cost,
and speed - Can categorize I/O devices by function
- User Interface Devices (keyboard, printer,
mouse, video, scanner) - Mass Storage Devices (disk, magnetic tape drive,
CD ROM drive) - Outside Communications (networks and gateways,
modems) - Or by Input versus Output
- Input (keyboard, mouse, scanner, CD ROM drive)
- Output (video, printer)
- Both (disk, magnetic tape drive, network, modem,
CD R/W)
4CS220 Computer OrganizationInput and Output
- The Keyboard (input)
- Simple input device, low data rate (as fast as
you can type) - When a key is pressed on the keyboard, an ASCII
character is sent to the processor. - Each key is said to be mapped to a particular
character. Mappings vary from keyboard to
keyboard. - Each bit of the ASCII character are sent to the
processor serially, over a single wire. - Baud rate the rate at which the bits are sent
to the processor (in bits per second) - The keyboard typically appends a start and stop
bit to the ASCII character to indicate to the
processor that it is sending it a character and
when it is done sending that character.
5CS220 Computer OrganizationInput and Output
- The Display (output)
- Video Display Terminal (glass teletype)
mimics the motions of a typewriter or teletype. - Attach a keyboard to a video display and you
have an ASCII Terminal - Cursor (flashing box, underscore)
- lines scrolled up as they were typed and a
carriage return was hit - when a key is hit on the keyboard, it appears on
the terminal - Enhanced or Smart Terminals
- A controller receives the character from the
processor and updates the screen appropriately - Capable of manipulating pixels instead of
printing at predetermined positions (known as
bit-mapped displays)
6CS220 Computer OrganizationInput and Output
- The Rigid Disk (extended or secondary memory)
- Input and Output
- Differs from main memory in that it
reads/writes large chunks of data at one time in
blocks. - Blocks are used because the time to read and
write to secondary memory is very long compare
with that of main memory. Also because space is
not addressed, but requires identifying tags to
be stored along with the data. - Physical characteristics
- One or more platters
- Two arms with one or more read/write heads per
platter to read each surface - Platters are connected by a spindle and all
rotate together around the axis of the spindle. - Platters are sealed to keep the platters clean.
7CS220 Computer OrganizationInput and Output
- The Rigid Disk (extended or secondary memory)
- Physical characteristics (continued)
- Data on platters are organized into tracks
(concentric circle) - Each track is broken into sectors
- Each sector in the same position on each track
of a platter is collectively called a cylinder - Reading/Writing Data
- Given an address, the disk must seek for the
proper position in a cylinder on the appropriate
platter. - The platter then must rotate until the proper
sector is positioned at its beginning, under a
read/write head and reading/writing must occur at
the precise moment that the proper sector is
rotating under that head - The processor MUST provide the bytes to write
at the proper time and at the proper rate for the
data to write to the patter correctly. When
reading, the processor MUST be ready to accept
the data at the speed that the disk provides it.
8CS220 Computer OrganizationInput and Output
- The Network (input and output)
- A computer can send or receive blocks of
information instead of single bits. - Network transfer rates vary depending on
bandwidth. Bandwidth represents the number of
bits per second that can be transferred. - LAN (local area network) versus WAN (wide area
network) - A combination of hardware and software
implements the functionality of a network
9CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- Basic interface involves the processor sending
and receiving bits from I/O devices. - The processor can process input and output
instructions much faster than the I/O devices can
supply or accept them. Of primary interest in
the interface is how to handle this difference. - Simple case
- The processor must know the status of each
device ready or busy
Processor
Memory
10CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- Implementation of status is as easy as using
one bit for the processor to look at to determine
if a device is ready or if it is busy. - Input/Output Programming
- Some architectures have special instructions
for I/O device communication. - Another way is to designate a section of memory
is set aside for memory-mapped I/O. - Memory-mapped I/O allows the processor to
access I/O without the need for new instructions.
Reading from or writing to these special memory
locations is all that is needed to receive input
or provide output.
11CS220 Computer OrganizationInput and Output
- Processor-I/O Interface - Input/Output
Programming - Actual memory locations in the mapped memory
are not used, but the data and device status must
be stored somewhere. - This can be done within the device itself, or,
more typically by special hardware called a
controller.
Processor
Display_Status
Display_Data
Memory
Keyboard_Status
Keyboard_Data
memory-mapped
mov EAX, dword ptr Keyboard_Data mov dword ptr
Display_Data, EAX
12CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- Code to implement I/O functions must take the
status of the device into account - Lets assume that a status with the most
significant byte of 1 as ready and zero as busy.
keyboard_wait test Keyboard_Status,
80000000h jz keyboard_wait mov EAX,
dword ptr Keyboard_Data
display_wait test Display_Status,
80000000h jz display_wait mov dword ptr
Display_Data, EAX
If no characters are being typed, the keyboard is
in a busy state. When a key is hit on the
keyboard, the controller gets the ASCII character
and places it in Keyboard_Data. It then changes
the Keyboard_Status to zero to indicate that it
is ready. The wait loop is then exited and the
processor can move the character to its regester.
13CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- In a simple system, the wait loops and
memory-mapped I/O are a good solution. It is
unrealistic outside of this simple system. - Current systems have many I/O devices and are
expected to run more than one program,
concurrently (multiprogramming). - In a more complex system, these programmed I/O
solutions have several problems - Cant waste processor resources sitting and
waiting for I/O devices, which are typically much
slower than the processor - Input devices might flip to the ready state
while the processor is working on executing
another program - If more than one program is running in the
multiprogrammed environment, if both need to use
an I/O device, there is nothing to keep track of
which program gets to use it
14CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- Solution to these problems is to let the
operating system handle it - Track what I/O device is available to each
program - Ensure that programs do not interfere with each
other - Provides methods for programs to request I/O
operations - The operating system may still use the wait
loops, but maintains them as part of the
operating system. The architecture may restrict
I/O instructions or access to mapped-memory to
the operating system and not allow access by
individual programs. - It is then the operating systems job to ensure
that the I/O devices are monitored and used
efficiently and correctly. For example, the
Keyboard_Status must be polled often enough such
that a Keyboard_Data gets transmitted to the
processor before the next keystroke overwrites it
and data is lost.
15CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- DMA (Direct Memory Access)
- To move a large amount of data at one time, for
example in mass storage devices or for network
transfers, programmed I/O would tie up the
processor for an extended period of time. - A controller for these types of devices can be
expanded to move data from the storage device to
memory, with only direction from the processor to
do so. - The processor, after providing the necessary
direction, is free to do other things. - The controllers for these devices become simple
computers executing a program that does DMA.
16CS220 Computer OrganizationInput and Output
- Processor-I/O Interface
- DMA (Direct Memory Access)
- The processor simple tells the controller the
details of the block transfer (Source,
Destination, How much). - The controller then does the transfer
independent of the processor.
Processor
DMA Controller
Disk
Memory
memory-mapped