CEN 351 – COMPUTER ORGANISATIONS AND ARCHITECTURE
(PROF S. ORIKE)
THE INPUT/OUTPUT SYSTEM
These are the systems and devices that are interfaced with the computer system. They are also
called peripherals. Examples include: Keyboard, mouse, monitor, scanner, printer, plotter,
network card, etc. The usefulness of a computer system depends on its input and output (I/O)
facilities. For many application programs, the I/O is the predominant factor. The speed with
which the program executes is determined primarily by the ability of its I/O operations to stay
ahead of its processing.
Both input and output are handled using the technique known as programmed I/O. There exist a
number of complicating factors in handling I/O process in a real computer. Although the method
of transferring data one word at a time may be adequate and appropriate for some slow operating
I/O devices, the volume of data commonly transferred from and to other I/O devices makes this
method too slow to be practical. Alternative methods of transferring data in blocks, rather than in
individual pieces of data are needed. Also, there may be many I/O devices all trying to do I/O
operations simultaneously.
There needs to be a way of distinguishing and separating the I/O from these different devices.
Additionally, devices operate at different speeds from each other and from the CPU.
Synchronization of different computer modules must be achieved to prevent data loss. Several
different techniques are combined to resolve the problem of synchronization and handling I/O
between a variety of different I/O devices that operate with different quantities of data at
different speeds.
Characteristics and Types of I/O Devices
The two most important characteristics that determine the effective and full usage of system
resources are: Speed of the data transfer and data quantity.
For example, the keyboard is a character-based input device, typing on the keyboard results in
ASCII input to the computer, one character at a time. Input from the keyboard is very slow
because it is dependent on the speed of typing, as well as the thought process of the user. Thus,
the rate of data transfer for keyboards is very slow compared to the speed at which the CPU
1
processes the data. There are two different types of keyboard inputs. First, there is input which is
expected by the application program. Secondly, there are times when the user wishes to interrupt
what the program is doing (for example: Control – C, Control – Alt – Delete), that is, the input
is unexpected. In addition, on a multi-user system, there may be many keyboards connected to
the computer. The computer must therefore be able to distinguish between them, must not lose
input data even if several keyboards send a character simultaneously, and must be able to
respond quickly to each keyboard.
Other input devices are: Pointing devices – mouse, light pens, etc; Touch screen; Voice/speech
input; Scanner; Source data automation, etc.
Mouse: This is a handy device which can be moved on a smooth surface to simulate the
movement of cursor that is desired on the display screen. It could be optical or mechanical.
Clicking on a mouse button may serve as expected input to a program, or it may be unexpected
and change the way in which the program is executing. The data rate of a mouse is also slow.
Light Pen: This is a pen-shaped device that allows natural movement on the screen. The pen
contains a light receptor, activated by pressing the pen against the display screen. Receptor is the
scanning beam that helps to locate the pen’s position.
Touch Screen: Some modern computers allow the users to make inputs into them by directly
touching the screen their fingers.
Voice/Speech Input: One of the most exciting areas of research is in recognizing human
voices/speech so that this could be inputted into computer directly. This approach will eliminate
the need for keying in data and will facilitate casual users to use the computer very easily.
Scanners: Scanners facilitate capturing of the information and storing them in a graphic format
for displaying back on the graphical screen. Scanners consist of two components – the first to
illuminate the page so that the optical image can be captured and the other to convert the optical
image into digital format for storage by the computer.
Source Data Automation: Most recent trends for data input are towards source data automation.
The equipment used for source data automation capture data as a by-product of a business
activity, thereby completely eliminating manual input of data. Some examples are:
2
o Magnetic Ink Character Recognition (MICR): These devices are generally used by the
banking industry to read the account numbers on cheques directly and do the necessary
processing.
o Optical Mark Recognition (OMR): These devices can sense marks on computer readable
papers. These devices are used by academic and testing institutions to grade aptitude
tests, where candidates mark the correct alternatives on a special sheet of paper. The
OMR devices then directly read these answer sheets and the information sent to a
computer for processing.
o Optical Bar-Code Reader (OBR): These devices scan a set of vertical bars of different
widths for specific data, and are used to read tags and goods in stores, medical records,
library books, etc. They are available as hand-held devices.
Output Devices
In output devices, the outputs are produced in two ways: either on display units/devices or on
papers. Output devices such as monitors (display screens) and printers must operate over a wide
range of data rates. This is especially important for graphical outputs, images and videos.
Graphical display is made up of series of dots, called pixels (picture elements), whose pattern
produces the image. There are three categories of display screen technology:
o Cathode Ray Tube (CTR) – driven by electromagnetic field;
o Liquid Crystal Display (LCD) –low energy requirements;
o Projection Display – use of overhead projectors.
Printers are used for producing outputs on papers. There are varieties of printing devices and
technologies. Printers can be categorised as:
a) Printing technology – Impact and non-impact printers. Impact printers use variations of
standard typewriter printing mechanism through inked ribbon, which non-impact printers
use chemical, heat or electrical signals to induce symbols on the paper.
3
b) Character forms – Fully forms characters and dot matrix. Fully formed characters are
constructed from solid lines and curve, while dot matrix character is made up from a
carefully arranged sequence of dots packed very close to each other.
c) Printing sequence – Serial, line and page. This indicates the amount of information a
printer can output within a single cycle of operation. Serial printing is done character by
character, whereas line printing forms an entire line at a time. A page printer outputs
whole page of characters and images simultaneously during one cycle.
d) Types – Various types of printers exist, including: Dot matrix, Ink jet, Desk jet, Laser
printers, etc.
Other I/O Devices
As a storage device, disks are also capable of both input and output. Massive amounts of data are
transferred quickly between the CPU and the disks. The I/O requirements of disks are different.
Disks are used to load entire programs or store files of data; hence their data is always
transferred in blocks, and not in individual bytes or words. In recent times, networks are
preferred as substitutes for disks, with data and programs stored at a remote computer and served
to the local station.
Most of the time, I/O devices operate completely under CPU program control. This means that it
is always a program executing in the CPU that initiates the I/O transfer. However, in some cases,
it is important to provide the facility of generating input to the CPU independently of program
control, i.e. unexpected input. The input from the keyboard, the mouse, any voice input device
and the network, all fall into this category.
The table below shows typical data rates for various I/O devices.
4
Data rate
Device Input/output
(Kbytes/sec)
Keyboard Input 0.01
Mouse Input 0.02
Voice input Input 0.02
Scanner Input 200
Voice output Output 0.5
Dot-matrix printer Output 1
Laser printer Output 100
Graphics display Output 30,000
LAN Input and Output 200 – 20,000
Optical disk Storage 500
Magnetic tape Storage 2,000
Magnetic disk Storage 2,000
I/O Instructions
To carry out input/output, the CPU issues I/O related instructions. These instructions consist of
two components:
o The address of the input/output device specifying the I/O device and I/O module;
o An input/output command.
5
There are four types of I/O Commands, which can be classified as: CONTROL, TEST, READ and
WRITE. CONTROL commands are used to control the specific instructions to the device. For
example, a magnetic tape requires rewinding or moving forward by a block. TEST command
checks the status of a device – if is ready or not, or is in error condition. READ command is used
for data input from a device and the WRITE command is used for data output to a device.
I/O Modules
There are several requirements needed to be met for a computer system to handle I/O in a
sufficient and effective manner:
o There must be a means for individually addressing different I/O devices.
o There must be a way for some I/O devices to initiate communication with the CPU (use
of drivers).
o Programmed I/O is suitable only for slow I/O devices and individual word transfers; for
faster devices with block transfers, there must be alternative means of transferring the
data between I/O and memory.
o There must be a means for handling devices with extremely different control
requirements, i.e. different I/O devices may require different formats of I/O, may operate
at different data transfer rates and may involve implementation of device-specific tasks.
It would be desirable if there was a simple and similar way to control different I/O
devices by programs in the CPU.
Depending on the particular operating system installed in the computer, it may not be practical to
connect the I/O devices directly to the CPU without an interface module, unique to each other
device. The different requirements for I/O devices plus the necessity for providing devices with
addressing, synchronization, status and external control capabilities, makes it needful to provide
each I/O device with its own special interface. Thus, in general, I/O devices are connected to the
CPU through an I/O module that contains the circuitry necessary to meet all the I/O
requirements.
6
An I/O module serves as an interface between the CPU and a specific device, accepting
commands from the CPU on one side and controlling the device on the other. The I/O module
performs the following functions:
o Recognizing messages addressed to it, and accepts commands from the CPU, establishing
what the corresponding I/O device is to do.
o Provides a buffer where the data can be held until it can be used.
o Provides the necessary registers and controls to perform a direct memory transfer.
o Provides an interface to the corresponding device controlling its operations.
o Provides interrupt capability, which is used to notify the CPU when the device is ready.
Generally, the I/O modules simplify the task of interfacing peripheral devices to the CPU,
thereby offloading a considerable amount of work from the CPU. Much of the power of modern
computers comes from the ability to separate CPU and I/O operations and from the ability to
execute a number of logically separate processes in parallel. The use of powerful I/O modules
helps to provide these capabilities.
Implementation of I/O
The input/output operations can be performed by three basic techniques. They are:
1. Programmed I/O;
2. Interrupt-driven I/O;
3. DMA
Programmed I/O
In the simplest method for performing I/O, an input/output module is connected to a pair of I/O
registers in the CPU via a bus as shown below: An input data from a peripheral device is
transferred under program control from an I/O module to the I/O register and to the accumulator.
Similarly, output data pass from an accumulator to the I/O register where they can be read by the
7
appropriate I/O module, also under program control. This method of I/O implementation is
known as programmed input/output.
CPU
I/O Data
Register I/O Module I/O Device
I/O Address I/O Module I/O Device
Register
I/O Device
Arrangement of I/O Modules
The I/O operations are completely controlled by the CPU. The CPU executes programs that
initiate, direct and terminate an I/O operation. It requires a little special I/O hardware, but is quite
time consuming for the CPU, since the CPU has to wait for slower I/O operations.
Programmed input/output is a useful I/O method for computers where hardware costs need to be
minimised. The input or output in such cases may involve:
o Transfer of data from I/O device to the CPU registers.
o Transfer of data from CPU registers to memory.
In this method, the responsibility of the CPU is to constantly check the status of the I/O device to
check whether it has become free (in case output is desired) or it has finished inputting the
current series of data (in case input is going on). Thus, programmed I/O is a very time
consuming method where the CPU wastes lot of time for checking and verifying the status of an
I/O device.
8
Interrupts-driven I/O
Another technique suggested to reduce the waiting by the CPU is interrupt-driven I/O. The CPU
issues the I/O command to I/O module and starts doing other work, which may be the execution
of a separate program. When the I/O operation is complete, the I/O module interrupts the CPU
by informing it that I/O has finished. The CPU then, may proceed with execution of this
program.
There are many circumstances under which it would be desirable to interrupt the normal flow of
a program in a computer to react to special events. Such circumstances include an unexpected
user command from a keyboard, an abnormal situation such as power failure, an attempt to
execute an illegal instruction or the completion of I/O task. All these suggest that it would be
appropriate to provide mechanism by which the computer can interrupt the normal processing of
the processor and can take special actions. The most common classes of interrupts are:
Descriptions
Class
Program Generated by some conditions that occur as a result of an instruction execution,
such as arithmetic overflow, division by zero, attempt to execute an illegal
machine instruction, reference outside a user’s allowed memory space, etc.
Timer Generated by a timer within the processor. This allows the processor to perform
certain functions on a regular basis.
I/O Generated by an I/O controller, to signal normal completion of an operation or to
signal a variety of error conditions.
Hardware Generated by a failure, such as power failure or memory parity error, equipment
Failure malfunction, etc.
9
From the user program point of view, an interrupt is just an alteration of the normal sequence of
execution. When the interrupt processing is completed, execution resumes. Interrupts are used as
means of causing the CPU to take special actions in response to unexpected input or events.
Servicing Interrupts
To accommodate interrupts, an interrupt cycle is added to the instruction cycle shown below:
Interrupt
Disabled
Check
No
START Fetch Next Execute for
Instruction Instruction Interrupt Interrupt
Enabled
HALT Yes
Process
Interrupts
Instruction cycle with interrupts
10
The processor checks to see if any interrupts have occurred, indicated by the presence of an
interrupt signal. If no interrupts are pending, the processor proceeds to the fetch-execute cycle. If
an interrupt is pending, the processor suspends execution of the current program and executes an
interrupt handler routine.
As soon as the interrupt handler gets control, it immediately performs a context switch to save all
general and status registers of the interrupted process. It the installs its own values for every CPU
registers so that it can handle the interrupt occurrence. The interrupt handler program after that
determines the appropriate course of actions to be performed. This process is known as servicing
the interrupt.
Uses of Interrupts
1. Interrupt as an external event notifier: Interrupts are useful as notifiers to the CPU of
the external events that require action. This frees the CPU from the necessity to perform
polling – to determine if input data is waiting.
2. Interrupt as a completion signal: Interrupts may be used to notify the computer of the
completion of a particular course of action.
3. Interrupt as a means of allocating CPU time: Interrupt is used as a method of allocating
CPU time to different programs that share the CPU, in conjunction with the operating
11
system. Each program is allowed to execute some instructions. After a certain period of
time, a program is interrupted and relinquishes control to a dispatch program within an
operating system. The operating system then allocates the next block of time to another
program.
4. Interrupt as an abnormal event indicator: To handle abnormal events that affects the
operation of the computer itself. These are events generated within the computer system,
for examples: power failure, illegal instructions – division by 0, hardware error- parity
error.
5. Software interrupts: Modern CPU instruction sets include an instruction that simulates
an interrupt. The interrupts instruction works in the same way as hardware interrupt,
saving appropriate registers and transferring control to an interrupt handling procedure.
Multiple Interrupts
In a computer system, there may be many I/O devices and internal processes requiring the
attention of the processor. Thus multiple interrupts will occur from time to time. When there are
a number of devices capable of generating an interrupt, there are two different processing
methods that are used for determining which device initiated the interrupt. They are vectored
interrupt and polled interrupt processing. In vectored interrupt, the address of the interrupting
device is included as part of the interrupt, while polled interrupt processing provides a general
interrupt routine that is shared by all devices. The computer identifies the interrupting device by
polling each device in turn.
When an interrupt occurs, there may be other interrupts already awaiting service. Here, two
approaches are available in servicing the interrupts:
1. To disable other interrupts while one is being processed. Here, the processor will ignore
the interrupt signal, which will remain pending and will be checked by the processor after
it has enabled them.
2. Masking the interrupts, that is, selectively disabling the interrupts by the processor.
12
Direct Memory Access
In some applications, it is impractical to transfer data between memory and peripheral devices
via the CPU. For instance, the data from disks is transferred only in blocks and it does not make
sense to execute a separate instruction from each piece of data in the block. The computer system
therefore provides a more efficient form of I/O that transfers block of data directly between the
I/O module and computer memory. The transfer is initiated by a program in the CPU, but the
CPU can then be bypassed for the remainder of the transfer. The I/O module will notify the CPU
when the transfer is complete. Once this has happened, the data in memory is ready to be used.
This technique of I/O – memory data transfer is known as direct memory access (DMA).
For DMA to take place, three primary conditions must be met:
1. There must be a method to connect together the I/O interface and memory.
2. The I/O module associated with a particular device must be capable of reading and
writing to memory.
3. There must be a way to avoid conflict between the CPU and the I/O module.
To initiate DMA transfer, the CPU needs the following pieces of data to be provided to the I/O
module:
1. The location of the data on the I/O device.
2. The starting location of the block of data in memory.
3. The size of the block to be transferred.
4. The direction of transfer.
CPU – Memory – I/O Architectures
There are various ways to interconnect the CPU, memory and I/O peripherals, each with its own
advantages and disadvantages. The basic pathways required in a CPU – Memory – I/O – System
involves the use of five basic components to interface the CPU and the I/O peripherals:
1. The CPU
2. I/O peripheral device
13
3. Memory
4. I/O Module
5. Buses
This is illustrated below:
The pathway requires a connection between the CPU and the I/O module to enable the CPU
issue programmed I/O commands, and also for the I/O to provide completion signals to the CPU;
a connection from the I/O module to the device and a connection between I/O module and
memory.
Although the above illustration implies that these pathways represent actual direct connections
between the various component blocks, this is not actually true. The connection could be direct
or they could be electronic switches that provide the connections at the time required. These
differences constitute different system architectures, representing different manufacturers and
goals.
There are two basic I/O system architectures in common use: Bus architecture and Channel
architecture. The bus architecture is used in almost all personal computers, while the channel
architecture is found primarily in IBM mainframe computers.
14
Bus I/O Architecture
In many systems, a bus forms the backbone for connection of various memory and I/O
components to the CPU. The system bus usually consists of a number of different interconnected
buses. Different buses are interconnected by bus interfaces, which expand the flexibility of the
system. The ability to interconnect buses makes possible the design and use of industry standard
buses on equipment of different vendors. The use of standard buses generally simplifies the
purchase, set-up, and proper operation of peripherals from different vendors. This is a major
aspect of the concept of open architecture.
Channel I/O Architecture
The channel I/O architecture is based on a separate I/O processor, known as a channel sub-
system. The I/O processor acts as a separate computer just for I/O operations, making the
computer CPU available for other tasks. The channel sub-system executes its own set of
instructions, known as channel control words, which are stored as programs in memory.
15
The channel sub-system is made up of sub-channels, each of which is connected through a
control unit to an individual I/O device by one or more channel paths. Information about
characteristics of each sub-channel and its corresponding device is kept in memory. Each sub-
channel is operated by executing a channel program, made up of channel control words. The
primary purpose of channel programs is to transfer data using DMA between an I/O device and
memory. The channel sub-system can perform several I/O functions simultaneously.
Examples:
Let's focus on calculations related to input/output performance, specifically data transfer rates
and storage capacity. These are common areas where calculations are needed.
Example 1: Hard Drive Transfer Rate
Problem: A hard drive has a transfer rate of 150 MB/s (megabytes per second). How long will it
take to transfer a file that is 3 GB (gigabytes) in size?
Solution:
• Convert GB to MB: 3 GB * 1024 MB/GB = 3072 MB
• Calculate transfer time: 3072 MB / 150 MB/s = 20.48 seconds
Answer: It will take approximately 20.48 seconds to transfer the file.
16
Example 2: Network Bandwidth
Problem: A network connection has a bandwidth of 1 Gbps (gigabits per second). How long will
it take to download a 500 MB file?
Solution:
• Convert Gbps to Mbps: 1 Gbps * 1000 Mbps/Gbps = 1000 Mbps
• Convert Mbps to MBps: 1000 Mbps / 8 bits/byte = 125 MBps (megabytes per second)
• Calculate download time: 500 MB / 125 MB/s = 4 seconds
Answer: It will take 4 seconds to download the file.
Example 3: Storage Capacity
Problem: A storage device has a capacity of 2 TB (terabytes). How many 4 GB movies can be
stored on the device?
Solution:
• Convert TB to GB: 2 TB * 1024 GB/TB = 2048 GB
• Calculate the number of movies: 2048 GB / 4 GB/movie = 512 movies
Answer: 512 movies can be stored on the device.
Example 4: Input/Output Operations per Second (IOPS)
Problem: A database needs to perform 10,000 read operations per second. If a hard drive can
perform 200 IOPS, how many hard drives are needed?
Solution:
• Calculate the number of drives: 10,000 IOPS / 200 IOPS/drive = 50 drives
Answer: 50 hard drives are needed.
Example 5: Calculating Data Transfer Over Time
Problem: A sensor generates data at a rate of 10 KB/s. How much data will it generate in 24
hours?
Solution:
• Convert KB/s to bytes/s: 10 KB/s * 1024 bytes/KB = 10240 bytes/s
• Convert 24 hours to seconds: 24 hours * 60 min/hour * 60 sec/min = 86400 seconds
• Calculate total data: 10240 bytes/s * 86400 s = 884,736,000 bytes
17
• Convert bytes to MB (optional): 884,736,000 bytes / (1024 bytes/KB * 1024 KB/MB) ≈
844 MB
Answer: The sensor will generate approximately 844 MB of data in 24 hours.
Exercises
1. Web Server Bandwidth:
Question: A web server needs to handle 10,000 requests per second. Each request results in a
200 KB response. What is the minimum required network bandwidth (in Mbps) for the server?
Answer:
• Calculate total data transfer per second: 10,000 requests/s * 200 KB/request = 2,000,000
KB/s
• Convert KB/s to MB/s: 2,000,000 KB/s / 1024 KB/MB ≈ 1953.125 MB/s
• Convert MB/s to Mbps: 1953.125 MB/s * 8 bits/byte ≈ 15625 Mbps
Therefore, the server needs a minimum bandwidth of approximately 15,625 Mbps or
15.625 Gbps. In practice, you'd likely want even more bandwidth to handle spikes in traffic.
2. Disk I/O for Database:
Question: A database application requires 5,000 read operations per second. The hard drive
being used has a rated IOPS (Input/Output Operations Per Second) of 250. How many hard
drives are needed to meet the application's requirements?
Answer:
• Calculate the number of drives needed: 5,000 read operations/s / 250 IOPS/drive = 20
drives
Therefore, 20 hard drives are required.
3. Video Streaming Bandwidth:
Question: A video streaming service needs to deliver 1080p video at a bitrate of 5 Mbps to
1,000 concurrent users. What is the total required network bandwidth (in Gbps)?
Answer:
• Calculate total bandwidth per user: 5 Mbps
• Calculate total bandwidth for all users: 5 Mbps/user * 1,000 users = 5,000 Mbps
• Convert Mbps to Gbps: 5,000 Mbps / 1000 Mbps/Gbps = 5 Gbps
Therefore, the streaming service needs a total bandwidth of 5 Gbps.
18
4. Data Backup Time:
Question: A company needs to back up 5 TB of data. They are using a backup system that can
transfer data at a rate of 100 MB/s. How long will the backup take (in hours)?
Answer:
• Convert TB to MB: 5 TB * 1024 GB/TB * 1024 MB/GB = 5,242,880 MB
• Calculate backup time in seconds: 5,242,880 MB / 100 MB/s = 52,428.8 seconds
• Convert seconds to hours: 52,428.8 seconds / 3600 seconds/hour ≈ 14.56 hours
Therefore, the backup will take approximately 14.56 hours.
5. Image Storage Capacity:
Question: A digital camera takes photos that are 10 MB each. How many photos can be stored
on a 64 GB memory card?
Answer:
• Convert GB to MB: 64 GB * 1024 MB/GB = 65,536 MB
• Calculate the number of photos: 65,536 MB / 10 MB/photo = 6553.6 photos
Therefore, approximately 6,553 photos can be stored on the memory card. (We round down
since you can't have fractions of photos.)
19