Journal 08 - maxinepopov/sys-140 GitHub Wiki
Computer systems employ five general I/O control methods which are programmed I/O, interrupt-driven I/O, memory-mapped I/O, direct memory access and channel attached I/O.
Programmed I/O or polled I/O is when the CPU continuously monitors a control register that is associated with each of the I/O ports. When bytes arrive into the port, a bit in control register is set. The CPU polls the port and takes notice that the data ready control bit is set. CPU resets the control bit, retrieves, and processes it according to the instructions programmed for that port. Once complete, CPU resumes polling the control registers. Benefit of this approach is that we have control over the behavior of each device (programming) and by modifying the few lines of code, we can adjust numbers and types of devices in systems, as well as polling priorities and intervals.
Interrupt-driven I/O = is thought of as the converse of programmed I/O. Instead of CPU asking its attached devices whether they have input, the devices tell CPU when they have the data to send. CPU proceeds with other tasks until the device requesting a service sends an interrupt to CPU. Interrupts are generated for every word of info that is transferred. Communication takes place through intermediary interrupt controller. Every peripheral device in systems have access to an interrupt request line.
Memory-mapped I/O = The I/O devices and main memory share the same address space. Each I/O devices contain its own reserved block of memories. The data transfers to and from the device and involves moving bytes to or from the memory addresses that are mapped to the device as well. It looks like memory access from the point of view of CPU.
Small systems = low-level details of data transfers are offloaded to I/O controllers built into I/O devices.
CPU moves data to and from I/O device when programmed I/O and interrupt driven I/O available.
Direct memory access (DMA) is when the CPU offloads execution of tedious I/O instructions. The CPU will provide the DMA controller with locations of bytes to be transferred, the number of them to be transferred, and the destination or memory address.
When proper values get placed into memory, CPU will signal the DMA subsystem and proceed with the next task, meanwhile the DMA will take care of details regarding the I/O. Once the I/O is complete or ends up failing, the subsystem signals CPU by sending it another interrupt.
The DMA controller and CPU share a bus. One of them at a time have control of the bus, which means they’re the bus master. I/O is prioritized over the CPU memory fetches for program instructions due to many I/O devices operating within tight margin parameters. If no activity is detected within a time frame, it will time out and abort the I/O process. The DMA uses memory cycles to avoid device timeouts which would originally be used by the CPU. That is called cycle stealing. I/O tends to create bursty traffic on bus, (data is sent in blocks or clusters).
I/O that is programmed will transfer data one byte at a time, meanwhile interrupt driven I/O can handle data one byte at a time. Depending on devices. DMA methods are block oriented. It interrupts the CPU only after completion or failure of the transferring of a group of bytes. Once DMA signals I/O completion, CPU will give it the address of next block of memory to either be read or written to. If there is failure, the CPU is responsible for taking action.
Large computer systems typically use an intelligent type of DMA known as I/O channel. It is traditionally used on mainframe computers, but it is now common on file servers and storage networks.
One or more I/O processors control various types of I/O pathways named channel paths. Channel paths for slow devices can be multiplexed which allows management of several of the devices through one controller.
A multiplexed channel path is called a multiplexor channel. Channels for disk drives or other fast devices are called selector channels.
I/O channels get driven by small CPUs that are named I/O processors or IOPs. They are optimized for I/O. IOPs have the ability to execute programs that include arithmetic log and branching instructions.
Programs consisting of a series of channel command words (CCWs). They also include actual transfer instructions and commands that control the I/O devices.
When I/O program gets placed into memory, host issues a start subchannel (SSCH). This informs the IOP of location in memory where the program will be found. Once the IOP completes its job, it will place completion information in the memory and send an interrupt to the CPU. After, the CPU obtains the completion information and takes appropriate measures to return codes.
Channel I/O is a type of isolated I/O. The IOP will use system memory bus to fetch its instructions from main memory.
7.4.2
Each key in a keyboard controls a small switch that will close a connection in a matrix of conductors that also run horizontally and vertically under the keys. Once the key switch closes, a scan code gets read by the keyboard circuitry. Scan code is passed to a serial interface circuit, and then translates the scan code into character code.
Magnetic disks and tapes store the data in blocks. Block I/O lends itself to the DMA or channel I/O processing. They can be different sizes depending on specific hardware, software, and applications.
Serial Transmission: Data-bit flows from one computer to another in bi-direction. One bit flows at one clock pulse, and 8 bits are transferred at a time having a start bit and stop bit.
Parallel Transmission: Bits all flow together simultaneously from one computer to another computer. It is faster than serial transmission to transmit the bits. This is used for short distance.
Q1: Interrupt-based would be the best control method for a keyboard. If you click on a key on keyboard, the interrupt based I/O sends a signal to CPU that it needs to carry the request for the keyboard click. The CPU is interrupted from its original tasks and tends to the keyboard.
Q2: Serial transmission would be good for long distance communication. For example, if you’re skyping someone from another country on your computer to their computer. Parallel tends to be used for shorter distances, but serial can be used for long distances.