Programmed I/O

What is Programmed IO (PIO)?

Programmed Input/Output, or PIO, refers to the specific mode of data transfer between one device and another, typically using the processor of the computer and not the memory or DMA.

Understanding Programmed IO (PIO)

What is Programmed IO (PIO)

Programmed IO uses the processor of the system to transfer data between devices instead of using the DMA or memory. That is why it is a relatively slower process as compared with Interrupt Driven IO.

This is done by the CPU by executing a particular program that allows it to have direct control over the entire operation.

Typically, the processor has to wait until the I/O operation is over after issuing the command to the I/O module. If it is faster, this results in costly wastage of COU power and time.

The I/O module in Programmed I/O performs the action requested and subsequently sets the correct bits in the status register of the I/O. Apart from that, it does not perform any other action, not even alerting the processor.

Typically, the PIO mode needs a lot of CPU overhead to function because it not only needs to configure a data transaction but also transfer the data.

This affects its efficiency and therefore paved the path for the Direct Memory Access and the Ultra Direct Memory Access interfaces to be created and to replace it with their enhanced performance.

However, DMA could not replace Programmed IO completely due to the fact that it needs simple digital logic to be implemented.

It is still a useful method today to transfer data and is typically used in specific settings where there is no need for high data transfer rates, such as in the embedded systems or with the Field Programmable Gate Array (FPGA) chips.

Using Programmed IO in these settings does not cause any significant performance loss.

Modes

There are different versions or modes of Programmed IO. Each of them supports a varied data transfer rate and the Advanced Technology Attachment standard. Here is the list summarized for you:

Read Also:  What is Direct Memory Access (DMA)? Function, Types & More

Remember, there is no PIO Mode 5 or anything beyond PIO Mode 4, and there are no plans for it either, though some hardware and computer manufacturers advertise that their Basic Input Output System (BIOS) will support PIO Mode 5.

However, a PIO Mode 5 was planned with an operational speed of 22 MB/s, but it was not applied on hard disks.

This is because the system would be crippled by the long wait times due to the high operational rate of PIO Mode 5. While no hard drive was built to support PIO 5, the DMA standard finally obviated it.

So, PIO Mode 5 is not suitable for the ATA standard but it can be used with the CompactFlash cards if they are linked to ATA through the CF-to-ATA adapters. These advanced timing modes perform as follows:

Operation

The operation of the CPU involves several stages and includes:

The processor also performs the job of pulling out data from the main memory of the system for output and also storing it there for input.

The input data transfer in Programmed IO mode happens in the following ways:

The output data transfer in Programmed IO mode happens in pretty much the same way and as follows:

I/O Commands

There are basically four different types of I/O commands used during the execution of the I/O-related instructions by the processor while issuing an address specifying the specific I/O module. These are:

I/O Instructions

There is a very close communication between the commands used and the instructions followed in Programmed IO. This is what happens in this process:

It is a simple one-to-one connection, where, ideally, the I/O instructions are typically mapped onto the I/O command.

Typically, according to the peripheral devices addresses, the I/O instructions can be customized as well.

Also, when the CPU, the I/O module, and the main memory all share one common bus, addressing is achieved in two specific ways. These are:

In memory-mapped I/O, the CPU uses one single address space to access the memory and I/O. This eventually means that the processor uses the following:

Therefore, the machine instruction addresses are also the same for both the I/O and the memory.

On the other hand, in the isolated I/O method, just as the name suggests, the address space for both the memory and that of the I/O is isolated.

However, the CPU uses the same data and address line for the I/O devices and the memory, but it uses a separate control line for the two.

This eventually means that there is a larger set of I/O instructions in the memory-mapped I/O as compared to that of the isolated I/O.

Therefore, in a Programmed IO mode, a program is written for every I/O operation or I/O transfer to perform the task instead of using interrupts as in DMA and Interrupted I/O.

Programmed IO Example

One of the most common examples of a computer device using Programmed I/O is the Advanced Technology Attachment (ATA) interface, though this specific interface can also be used in several different Direct Memory Access (DMA) modes.

Apart from that, there are also several other older devices used in a computer system that use Programmed IO as well. The list includes, but is not limited to:

Advantages

Disadvantages

Programmed IO Vs Interrupt Driven IO

Read Also:  What is Memory Bus? Components, Function & More

Conclusion

Ideally, with Programmed I/O mode of data transfer, the CPU of the computer is in control of the data exchange between it and the I/O module.

It is the simplest I/O mode where all is done by the CPU.

Though Direct Memory Access is more commonly used, PIO mode is still used today where speed is not the top priority.