Coa Assignment-4: Akshit Aggarwal CS63 171294
Coa Assignment-4: Akshit Aggarwal CS63 171294
Akshit Aggarwal
CS63
171294
Ans1. Programmed I/O:-Programmed I/O (PIO) refers to data transfers initiated by a CPU
under driver software control to access registers or memory on a device. The CPU issues a
command then waits for I/O operations to be complete. As the CPU is faster than the I/O
module, the problem with programmed I/O is that the CPU has to wait a long time for the I/O
module of concern to be ready for either reception or transmission of data.
The CPU, while waiting, must repeatedly check the status of the I/O module, and this process
is known as Polling. As a result, the level of the performance of the entire system is severely
degraded.
Programmed I/O basically works in these ways:
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
Advantages & Disadvantages of Programmed I/O
Advantages - fast
- efficient
Disadvantages - can be tricky to write if using a low level language
Direct Memory Access (DMA):-Direct Memory Access (DMA) means CPU grants I/O
module authority to read from or write to memory without involvement. DMA module
controls exchange of data between main memory and the I/O device. Because of DMA
device can transfer data directly to and from memory, rather than using the CPU as an
intermediary, and can thus relieve congestion on the bus. CPU is only involved at the
beginning and end of the transfer and interrupted only after entire block has been
transferred.
Direct Memory Access needs a special hardware called DMA controller (DMAC) that
manages the data transfers and arbitrates access to the system bus.
The controllers are programmed with source and destination pointers (where to read/write
the data), counters to track the number of transferred bytes, and settings, which includes
I/O and memory types, interrupts and states for the CPU
cycles.
DMA increases system concurrency by allowing the CPU to perform tasks while the
DMA system transfers data via the system and memory busses. Hardware design is
complicated because the DMA controller must be integrated into the system, and the
system must allow the DMA controller to be a bus master. Cycle stealing may also be
necessary to allow the CPU and DMA controller to share use of the memory bus.
Advantages & Disadvantages of DMA
•While the 8237A is using the buses to transfer data, the processor is idle. Similarly,
when the processor is using the bus, the DMA is idle.
•The 8237 DMA is known as a fly-by DMA controller. This means that the data being
moved from one location to another does not pass through the DMA chip and is not
stored in the DMA chip.
•Therefore, the DMA can only transfer data between an I/O port and a memory address,
but not between two I/O ports or two memory locations. However, the DMA chip can
perform a memory-to-memory transfer via a register which can temporarily hold the data.
•Phase 1: Initially, when the microprocessor-controlled devices were first introduced the
CPU directly controls a peripheral device.
•Phase 2: Then a controller or I/O module is added to the system configuration in which
the CPU uses programmed I/O without the interrupts.
•Phase 3: Interrupts are employed so that the CPU need not spend time waiting for an I/O
operation to be performed, thus increasing efficiency.
•Phase 4: During this evolutionary phase the I/O module is given direct access to memory
via DMA. The I/O device can now move a block of data to or from memory without
involving the CPU, except at the beginning and end of the transfer.
•Phase 5: Now, the I/O module is enhanced with a specialized instruction set tailored for
I/O operations. It is termed as the I/O channel, which is capable of fetching and executing
the I/O instructions without CPU intervention.
•Phase 6: The I/O module now has a local memory of its own and is, in fact, known as
I/O processor. With this architecture, a large set of I/O devices can be
controlled , with minimal CPU involvement.
Ques.3. a. Consider a system in which a data transfer over a bus
takes 500 ns. Transfer of bus control in either direction, from
processor to I/O device or vice versa, takes 250 ns. One of the
I/O devices has a data transfer rate of 50 KB/s and employs
DMA. Data are transferred one byte at a time. Suppose we
employ DMA in a burst mode. For how long would the device
tie up the bus when transferring a block of 128 bytes?
b.An I/O device transfers 10 MB/s of data into the memory of a
processor over the I/O bus, which has a total data transfer
capacity of 100 MB/s. The 10 MB/s of data is transferred as 2500
independent pages of 4 KB each. If the processor operates at 200
MHz, it takes 1000 cycles to initiate a DMA transaction, and
1500 cycles to respond to the device's interrupt when the DMA
transfer completes, what fraction of the processor's time is spent
handling the data transfer with and without DMA?
b.Initiating each DMA and responding to the interrupt at the end of each
transfer. This takes 2500 cycles/transfer, or a total of 6,250,000 cycles
(2500 pages * 2500 cycles/page transfer) spent handling DMAs each
second. Since the processor operates at 200 MHz. this means that 3.125
percent of each second, or 3.125 percent of the processor's time