1. Overview

In this tutorial, we’ll discuss various methods involved in I/O operations. We’ll talk about two types of programmed I/O: memory-mapped and isolated I/O.

Finally, we’ll present the core differences between them.

2. Introduction to I/O

I/O stands for input/output. I/O is a term to describe communication between the outer world, including humans and a computer using peripheral devices. Some of the most common peripheral devices attached to a computer are keyboards, mouses, monitors, network adapters, and printers. Peripheral devices exchange information between the outer world and computer CPUs. Some I/O devices act as input devices, some as output devices, while others act as both.

We pass the information to I/O devices from the CPU. We store the information passed from I/O devices to the CPU in memory. The CPU processes the data stored in memory and helps in transferring the data in an I/O operation.

In order to work efficiently within a system driven by a processor, I/O devices need an interface. It’s popularly known as the I/O interface. In general, the communication between the CPU and I/O devices occurs via a bus. The role of an I/O interface is to identify the address of the devices generated by the CPU. Additionally, an I/O interface includes facilitates an interface for the CPU to communicate with I/O devices.

3. Various Methods in I/O Operations

There’re three types of I/O techniques: programmed I/O, interrupt-driven I/O, and direct memory access. Let’s discuss each type of I/O technique briefly.

Let’s talk about the programmed I/O first. It’s a data transmission method between the CPU and networking peripheral devices using the I/O interface. Additionally, a computer program running on the CPU initiates I/O operations in programmed I/O. The CPU controls the entire I/O operation. Therefore, programmed I/O keeps the CPU busy. We can further divide programmed I/O into memory-mapped and isolated I/O. Isolated I/O is popularly referred to as mapped or port mapped I/O.

Next, let’s talk about interrupt-driven I/O. Interrupt-driven I/O is a technique in which the CPU doesn’t need to wait to check if the I/O device is ready or not, unlike programmed I/O. I/O device generates an interrupt to the CPU when the I/O device is prepared for I/O operation to take place. An example of a software interrupt is a signal to end a program like Microsoft Word so the CPU can speed up other programs like Microsoft Excel.

In the direct memory access (DMA) method, we transfer data directly between computer memory and I/O devices connected with a system. In this method, we don’t need to involve the CPU in the process of data transfer. DMA is an advantageous method for transferring a large amount of data as the CPU will be free while the data transfer takes place. Additionally,  hardware, including hard drives, graphics cards, and network cards for which transferring large amounts of data is important, uses the DMA method.

4. Isolated and Memory Mapped I/O

We can further divide programmed I/O into two categories: memory-mapped and isolated I/O.

There’re three types of buses required for I/O communication: address bus, data bus, and control bus. We assign an address to each I/O device for the CPU to communicate to that device using its address.

In memory-mapped I/O, both memory and I/O devices use the same address space. We assign some of the memory addresses to I/O devices. The CPU treats I/O devices like computer memory. The CPU either communicates with computer memory or some I/O devices depending on the address. Therefore, we reserve a part of the address space for I/O devices, which is not available for computer memory.

In the case of memory-mapped I/O, all the buses are the same for both memory and I/O devices. Therefore, building a CPU that uses memory-mapped I/O is easier and cheaper. Additionally, such CPUs consume less power due to reduced complexity. One advantage of memory-mapped I/O is that we don’t need separate instruction sets for accessing I/O devices. Instructions used for accessing memory can be easily used for accessing I/O devices.

In the case of isolated I/O, we provide a separate address space other than a memory address space to I/O devices. The addresses of I/O devices are also referred to as ports. I/O devices and memory use the same address and data bus. However, the control bus is different for data and memory:

MemoryMappedVsPortMapped

Therefore, isolated I/O becomes costlier compared to memory-mapped I/O. The isolated I/O technique has its own dedicated instruction set for accessing I/O devices. The CPUs that use isolated I/O are bigger and more complex to build.

For I/O devices, it doesn’t matter whether memory mapped or isolated I/O is implemented. I/O devices behave in the same manner independent of the I/O method implemented internally.

5. Differences

Now, let’s look at the core differences between memory-mapped and isolated I/O:

Isolated I/O

Memory-mapped I/O

Different address spaces are used for computer memory and I/O devices. I/O devices have dedicated address space.

Same address space is used for memory and I/O devices.

Separate control unit and control instructions are used in case of I/O devices.

Control units and instructions are same for memory and I/O devices.

More complex and costlier than memory -mapped I/O as more bus are used.

Easier to build and cheap as it’s less complex.

Entire address space can be used by memory as I/O devices have separate address space.

Some part of the address space of computer memory is consumed by I/O devices as address space is shared.

Computer memory and I/O devices use different control instructions for read write.

Computer memory and I/O devices can both use same set of read and write instructions.

Separate control bus is used for computer memory and I/O devices. Though same address and data bus are used.

Address, data and control bus are same for memory and I/O devices.

6. Conclusion

In this tutorial, we discussed the various methods in I/O operations. We explored two types of programmed I/O: memory-mapped and isolated I/O, in detail.

Finally, we presented the core differences between memory-mapped and isolated I/O.