What is a programmed I/O?

Programmed I/O is one of the simplest forms of I/O where the CPU directly controls and monitors all I/O operations. In this technique, the CPU is responsible for transferring data between memory and I/O devices, constantly checking device status and waiting for operations to complete.

How Programmed I/O Works

The CPU uses special instructions to read from and write to device registers. It continuously polls the device status register to determine when the device is ready for the next operation. This method requires the CPU's full attention during I/O operations.

Example − Printing "TUTORIALS" String

Consider a user process that wants to print the nine-character string "TUTORIALS" on a printer using a serial interface.

String Buffer in User Space T U T O R I A L S Buffer containing the string to be printed T Current

Step-by-Step Execution

Step 1 − The user process acquires the printer by making a system call to open it for writing.

Step 2 − If the printer is busy, the system call either fails with an error code or blocks until the printer becomes available.

Step 3 − Once available, the process makes a system call to print the string.

Step 4 − The operating system copies the user buffer to kernel space for processing.

Step 5 − The OS checks printer availability and copies the first character 'T' to the printer's data register using memory-mapped I/O.

Step 6 − The system marks 'U' as the next character to be printed and waits.

Step 7 − After copying the character, the OS checks if the printer is ready for the next character.

Step 8 − Writing to the data register sets the printer status to "not ready" in the status register.

Step 9 − When the printer controller finishes processing the current character, it updates the status register to indicate readiness.

Step 10 − The OS continuously polls the status register, waiting for the "ready" status.

Step 11 − Once ready, the OS sends the next character and repeats the process.

Step 12 − This loop continues until all characters in "TUTORIALS" have been printed.

Step 13 − Control returns to the user process after completing the entire string transfer.

Characteristics

Aspect Description
CPU Involvement High − CPU actively manages every byte transfer
Polling Method Continuous status checking until device is ready
Efficiency Low − CPU cycles wasted waiting for slow devices
Implementation Simple − Direct register access using special instructions

Advantages and Disadvantages

Advantages:

  • Simple to implement and understand

  • No special hardware required beyond basic I/O ports

  • Direct CPU control over timing and data transfer

Disadvantages:

  • CPU remains busy during entire I/O operation (busy waiting)

  • Inefficient for slow devices like printers or disks

  • Cannot perform other tasks while waiting for I/O completion

Conclusion

Programmed I/O provides direct CPU control over I/O operations through continuous polling of device status registers. While simple to implement, it is inefficient for modern systems due to CPU time wastage during device wait periods, making it suitable mainly for simple embedded systems or fast devices.

Updated on: 2026-03-17T09:01:38+05:30

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements