CHAPTER-5
Interfacing and Communication
5.1 I/O Fundamental
• Input/output or I/O is the communication between an information
processing system, such as a computer, and the outside world, possibly a
human or another information processing system.
• I/O subsystem of a computer provides an efficient mode of
communication between the central system and the outside environment.
It handles all the input-output operations of the computer system.
• Inputs are the signals or data received by the system and outputs are the
signals or data sent from it.
• I/O devices are the pieces of hardware used by a human (or other
system) to communicate with a computer.
• It includes: I/O devices and bus.
– Input devices: keyboard or mouse, etc.
– Output devices: monitors, printers, etc.
– Bus is a communication system/ medium that transfers data between
components inside a computer, or between computers
• Devices for communication between computers, such as modems and
network cards, typically perform both input and output operations.
Modem
Fig: Modem acts as both input and output device
Network interface card (also known as a NIC, network card, or network interface controller)
is an electronic device that connects a computer to a computer network, usually a LAN.
5.2 I/O Techniques
• The binary information that is received from an external device is usually
stored in the memory unit.
• The information that is transferred from the CPU to the external device is
originated from the memory unit.
• CPU merely processes the information but the source and target is always the
memory unit.
• Data transfer between CPU and the I/O devices may be done in different
modes.
• Data transfer to and from the peripherals may be done in any of the three
possible way Or 3 basic methods for managing input and output devices are
known as I/O techniques, which are:
1. Programmed I/O
2. Interrupt- initiated I/O
3. Direct memory access( DMA)
• I/O module: It is a device that acts as the connective bridge between a
computer system and I/O or peripheral device, such as a printer, webcam or
scanner.
1. Programmed I/O
• Most simple type of I/O technique for the exchanges of data or any
types of communication between the processor and the external
devices.
• CPU controls the entire process i.e. CPU always checks for the devices
for services(I/O operations).
• Concept: the CPU asks for service required to each device means CPU
polls each device to see if it needs servicing. Like in a restaurant, the
waiter would approach to each customer and ask for service.
• Also known as polling.
– Polling is the process where the computer or controlling device waits for an
external device to check for its readiness or state.
– For example, when a printer is connected via a parallel port, the computer waits
until the printer has received the next character.
• Can waste CPU time i.e. when CPU is faster than the I/O module then
this method is wasteful.
• In this case it requires constant monitoring by the CPU of the
peripheral devices.
Basic Operations in Programmed I/O:
• CPU requests I/O operation
• I/O module performs operation
• I/O module sets status bits
• CPU checks status bits periodically
• I/O module does not inform CPU directly
• I/O module does not interrupt CPU
• CPU may wait or come back later
OR
Fig: Flow Chart for Programmed I/O
2. Interrupt-Driven I/O
• In the programmed I/O method, the CPU stays in the program
loop until the I/O unit indicates that it is ready for data transfer.
This is time consuming process because it keeps the processor
busy needlessly.
• This problem can be overcome by using interrupt initiated I/O.
In this when the interface determines that the peripheral is ready
for data transfer, it generates an interrupt. After receiving the
interrupt signal, the CPU stops the task which it is processing and
service the I/O transfer and then returns back to its previous
processing task.
• Interrupt is an input signal to the processor indicating an event
that needs immediate attention.
• Concept:
– CPU provides the service to the device on request/demand.
– Overcomes CPU waiting
– Avoids repeated checking of device by CPU (polling)
Basic Operations of Interrupt driven I/O:
• CPU issues read command
• I/O module gets data from peripheral while CPU does other work
• I/O module interrupts CPU
• CPU requests data
• I/O module transfers data
CPU perform other task until it gets
OR interrupt from I/O module
CPU perform I/O operation
Fig: Flow chart for Interrupt-Driven I/O
3. DMA (Direct Memory Access)
• Both interrupt driven and programmed I/O require active CPU
involvement:
– Processor must transfer data
– Read from device or memory
– Write to memory or device
– Transfer rate is limited
– CPU is tied up (long waiting process)
• DMA allows devices to communicate directly with memory
without passing data through the CPU.
• Concept: Removing the CPU from the path and letting the
peripheral device manage the memory buses directly would
improve the speed of transfer. During DMA transfer CPU is idle.
(I/O)
CPU’s normal DMA executes I/O
task execution operation without
using CPU
Modes of DMA
i) Burst mode
ii) Cycle stealing mode
iii) Transparent mode
i) Burst mode:
– Also known as Block transfer mode.
– Entire block of data is transferred in one contiguous sequence.
• Ones data transmission is started, complete data will be
transferred.
– Fast mode.
– CPU remains idle for long time.
– Useful for loading program of files into memory.
ii) Cycle Stealing mode:
– CPU and DMA controller share the clock cycle i.e. first clock cycle is
used by CPU and next by DMA controller and process is repeated i.e.
DMA steals the cycle of CPU.
– CPU is not idle for long time as Burst mode.
– Slower than Burst mode because not all data is transferred at a time.
– Useful for controller monitoring system.
iii) Transparent mode:
– Most efficient in terms of processing time.
– DMA controller takes control of system bus only when CPU
is not using it.
– Slowest mode because DMA transfers data only when CPU
is not using system bus.
– It requires some additional hardware to detect the state of
CPU.
– CPU is not idle in this mode.
5.3 Interrupt
• An interrupt is a signal from a device attached to a computer or
from a program within the computer that requires the
operating system to stop and figure out what to do next.
• When a Process is executed by the CPU and when a user Request
for another Process then this will create disturbance for the
Running Process. This is also called as the Interrupt.
• Interrupts can be generated by User, Some Error Conditions and
also by Software’s and the hardware’s.
• CPU handles all Interrupts very carefully.
• It helps the computer to do multitask at a time.
• There are 2-main classes of interrupts:
i) Maskable
ii) Non-maskable
Types of Interrupt
Hardware Interrupt Software Interrupt
Maskable Non-Maskable
Interrupt Interrupt
Normal Exception
Types of Interrupt:
a) Hardware Interrupt:
– If the signal for the processor is from external device
or hardware is called hardware interrupts.
– Example: pressing of key in keyboard will generate a
signal which is given to the processor to do some
action and moving mouse, etc.
– Hardware interrupts can be classified into two types :
• Maskable Interrupt: The hardware interrupts
which can be delayed when a much highest
priority interrupt has occurred to the processor.
• Non Maskable Interrupt: The hardware which
cannot be delayed and should process by the
processor immediately.
i) Maskable Interrupt:
• An Interrupt that can be disabled or ignored by the
instructions of CPU.
• After completion of currently executing operation,
CPU handles these interrupts.
ii) Non-maskable Interrupt:
• It is a hardware interrupt that cannot ignore. And given
attention all the time.
• CPU handles these interrupts immediately by holding
currently executing operation and after handling
interrupt previously executed operation will resume.
• It typically occurs to signal attention for non-
recoverable hardware errors.
b) Software Interrupts:
• Software interrupt can also divided in to two types:
– Normal Interrupts: The interrupts which are caused by the software
instructions are called software interrupt.
– Exception: Unplanned interrupts while executing a program is called
Exception. For example: While executing a program if we got a value
which should be divided by zero is called a exception.
Classification of Interrupts According to Periodicity of Occurrence:
– Periodic Interrupt: If the interrupts occurred at fixed interval in timeline
then that interrupts are called periodic interrupts
– Aperiodic Interrupt: If the occurrence of interrupt cannot be predicted
then that interrupt is called aperiodic interrupt.
Interrupt Handling
• The interrupt handler is also called as Interrupt service routine
(ISR).
• There are different types of interrupt handler which will handle
different interrupts.
• For example for the clock in a system will have its interrupt
handler, keyboard it will have its interrupt handler for every
device it will have its interrupt handler.
• Type of Interrupt Handlers:
– First Level Interrupt Handler (FLIH) is hard interrupt handler or fast
interrupt handler. These interrupt handlers have more jitter while process
execution and they are mainly maskable interrupts.
– Second Level Interrupt Handler (SLIH) is soft interrupt handler and slow
interrupt handler. These interrupt handlers are having less jitter.
• Jitter: variation in arrival time during data transmission and
variation in total execution time in processing.
Methods to prevent occurrence of interrupt(Interrupt handling):
CPU periodically check each device to see if it needs service.
Give each device a wire (interrupt line) that it can use to give
signal to the processor.
Interrupts
Device-1
Interrupts
Interrupt Device-2
CPU Controller Device-3
Device-n
Interrupt Controller: Device interrupts are fed to the processor using a special
piece of hardware called interrupt controller. It manages all interrupts.
• Advantages:
– It increases the efficiency of CPU.
– It decreases the waiting time of CPU.
– Stops the wastage of instruction cycle.
• Disadvantages:
– CPU has to do a lot of work to handle interrupts, resume its
previous execution of programs ( overhead required to
handle the interrupt request).
5.4 Memory system design and Interfacing
• Memory components:
– RAM memory cells and cell arrays
– Static RAM–more expensive, but less complex
– Tree and Matrix decoders–needed for large RAM chips
– Dynamic RAM–less expensive, but needs “refreshing”
– Chip organization
– Timing
– ROM–Read only memory
• Memory Boards
– Arrays of chips give more addresses and/or wider words
– 2-D and 3-D chip arrays
• Memory Modules
– Large systems can benefit by partitioning memory for
• separate access by system components
• fast access to multiple words
The CPU–Main Memory Interface
• Sequence of events:
Read:
1. CPU loads MAR, issues Read, and REQUEST
2. Main Memory transmits words to MDR
3. Main Memory asserts COMPLETE.
Write:
4. CPU loads MAR and MDR, asserts Write, and
REQUEST
5. Value in MDR is written into address in MAR.
6. Main Memory asserts COMPLETE.
5.5 Buses
• It is a communication system that transfers data between
components inside a computer, or between computers.
• The electrically conducting path along which data is transmitted
inside any digital electronic device.
• A Computer bus consists of a set of parallel conductors, which
may be conventional wires, copper tracks on a PRINTED CIRCUIT
BOARD, or microscopic aluminum trails on the surface of a
silicon chip.
Functions of Bus
• Data sharing- All types of buses found in a computer
transfer data between the computer peripherals
connected to it.
• Addressing - A bus has address lines, which match
those of the processor. This allows data to be sent to
or from specific memory locations.
• Power - A bus supplies power to various peripherals
connected to it.
• Timing - The bus provides a system clock signal to
synchronize the peripherals attached to it with the rest
of the system.
Types of Bus
1. Data bus:
– One of the most common types of buses
– Data bus carries data from on component to another.
– Data flow is bi-directional for all.
– It is used to transfer data between the different devices on a computer.
– Data buses consist of different amount of lines which in turn affects
the speed/time of data transfer. (8, 16, 32, or 64 lines).
– CPU can read data and write data using these lines.
2. Control bus
– Control bus carries control signal. CU of CPU uses control signal for
controlling all the components.
– It is bi-directional for all components.
– It is used when needing to sort out different commands.
– It allows the data and address buses to be used in a timely manner as
well as specifying the different types of operations that need to be
performed at the time.
3. Address bus
– Everything has an ID so it can easily be reached using a bus. The ID of a
component is called the address.
– Address bus carries memory address.
– A memory address is a numerical value used for identifying a memory
location.
– Computer performs all its task through the memory address.
– It is uni-directional for all components.