In this Module, we have four lectures, viz. Show
Click the proper link on the left side for the lectures Input/Output Organization
There are several reasons why an I/O device or peripheral device is not directly connected to the system bus. Some of them are as follows -
Thus, an I/O module is required. Input/Output Modules The major functions of an I/O module are categorized as follows –
During any period of time, the processor may communicate with one or more external devices in unpredictable manner, depending on the program's need for I/O. The internal resources, such as main memory and the system bus, must be shared among a number of activities, including data I/O. Control & timings: The I/O function includes a control and timing requirement to co-ordinate the flow of traffic between internal resources and external devices. For example, the control of the transfer of data from an external device to the processor might involve the following sequence of steps –
If the system employs a bus, then each of the interactions between the processor and the I/O module involves one or more bus arbitrations. Processor & Device Communication During the I/O operation, the I/O module must communicate with the processor and with the external device. Processor communication involves the following -
On the other hand, the I/O must be able to perform device communication. This communication involves command, status information and data. Data Buffering: An essential task of an I/O module is data buffering. The data buffering is required due to the mismatch of the speed of CPU, memory and other peripheral devices. In general, the speed of CPU is higher than the speed of the other peripheral devices. So, the I/O modules store the data in a data buffer and regulate the transfer of data as per the speed of the devices. In the opposite direction, data are buffered so as not to tie up the memory in a slow transfer operation. Thus the I/O module must be able to operate at both device and memory speed. Error Detection: Another task of I/O module is error detection and for subsequently reporting error to the processor. One class or error includes mechanical and electrical malfunctions reported by the device (e.g. paper jam). Another class consists of unintentional changes to the bit pattern as it is transmitted from devices to the I/O module. Block diagram of I/O Module is shown in the Figure 6.1.
There will be many I/O devices connected through I/O modules to the system. Each device will be indentified by a unique address. When the processor issues an I/O command, the command contains the address of the device that is used by the command. The I/O module must interpret the addres lines to check if the command is for itself. Generally in most of the processors, the processor, main memory and I/O share a common bus(data address and control bus). Two types of addressing are possible -
Memory-mapped I/O: There is a single address space for memory locations and I/O devices. The processor treats the status and address register of the I/O modules as memory location. For example, if the size of address bus of a processor is 16, then there are 216 combinations and all together 216 address locations can be addressed with these 16 address lines. Out of these 216 address locations, some address locations can be used to address I/O devices and other locations are used to address memory locations. Since I/O devices are included in the same memory address space, so the status and address registers of I/O modules are treated as memory location by the processor. Therefore, the same machine instructions are used to access both memory and I/O devices Isolated or I/O -mapped I/O: In this scheme, the full range of addresses may be available for both. The address refers to a memory location or an I/O device is specified with the help of a command line. In general command line is used to identify a memory location or an I/O device. if =1, it indicates that the address present in address bus is the address of an I/O device. if =0, it indicates that the address present in address bus is the address of a memory location. Since full range of address is available for both memory and I/O devices, so, with 16 address lines, the system may now support both 2 16 memory locations and 2 16 I/O addresses. Input / Output Subsystem There are three basic forms of input and output systems – ·
Programmed I/O · Interrupt driven I/O
· Direct Memory Access(DMA) With programmed I/O, the processor executes a program that gives its direct control of the I/O operation, including sensing device status, sending a read or write command, and transferring the data. With interrupt driven I/O, the processor issues an I/O command, continues to execute other instructions, and is interrupted by the I/O module when the I/O module completes its work. In Direct Memory Access (DMA), the I/O module and main memory exchange data directly without processor involvement. With both programmed I/O and Interrupt driven I/O, the processor is responsible for extracting data from main memory for output operation and storing data in main memory for input operation.
To read data from an input device, the CPU simply moves data from the address (I/O or memory) of that device into the CPU. Input/Output Operation: The input and output operation looks very similar to a memory read or write operation except it usually takes more time since peripheral devices are slow in speed than main memory modules. The working principle of the three methodds for input of a Block of Data is shown in the Figure 6.2. Figure 6.2: Working of three techniques for input of block of data. Input/Output Port An I/O port is a device that looks like a memory cell to the computer but contains connection to the outside world. An I/O port typically uses a latch. When the CPU writes to the address associated with the latch, the latch device captures the data and makes it available on a set of wires external to the CPU and memory system. The I/O ports can be read-only, write-only, or read/write. The write-only port is shown in the Figure 6.3. Figure 6.3: The write only port First, the CPU will place the address of the device on the I/O address bus and with the help of address decoder a signal is generated which will enable the latch.
If it is in a read operation, the data that are already stored in the latch will be transferred to the CPU. A read only (input) port is simply the lower half of the Figure 6.4. In case of I/O mapped I/O, a different address space is used for I/O devices. The address space for memory is different. In case of memory mapped I/O, same address space is used for both memory and I/O devices. Some of the memory address space are kept reserved for I/O devices. To the programmer, the difference between I/O-mapped and memory-mapped input/output operation is the instruction to be used. For memory-mapped I/O, any instruction that accessed memory can access a memory-mapped I/O port. I/O-mapped input/output uses special instruction to access I/O port. Generally, a given peripheral device will use more than a single I/O port. A typical PC parallel printer interface, for example, uses three ports, a read/write port, and input port and an output port. The read/write port is the data port ( it is read/write to allow the CPU to read the last ASCII character it wrote to the printer port ). The input port returns control signals from the printer. The
output port transmits control information to the printer such as Memory-mapped I/O subsystems and I/O-mapped subsystems both require the CPU to move data between the peripheral device and main memory. For example, to input a sequence of 20 bytes from an input port and store these bytes into memory, the CPU must send each value and store it into memory. Programmed I/O: In programmed I/O, the data transfer between CPU and I/O device is carried out with the help of a software routine. When a processor is executing a program and encounters an instruction relating to I/O, it executes that I/O instruction by issuing a command to the appropriate I/O module. The I/O module will perform the requested action and then set the appropriate bits in the I/O status register. The I/O module takes no further action to alert the processor. It is the responsibility of the processor to check periodically the status of the I/O module until it finds that the operation is complete. In programmed I/O, when the processor issuses a command to a I/O module, it must wait until the I/O operation is complete. Generally, the I/O devices are slower than the processor, so in this scheme CPU time is wasted. CPU is checking the status of the I/O module periodically without doing any other work. I/O Commands To execute an I/O-related instruction, the processor issues an address, specifying the particular I/O module and external device, and an I/O command. There are four types of I/O commands that an I/O module will receive when it is addressed by a processor – · Control : Used to activate a peripheral
device and instruct it what to do. For example, a magnetic tape unit may be instructed to rewind or to move forward one record. These commands are specific to a particular type of peripheral device. ·
Test : Used to test various status conditions associated with an I/O module and its peripherals. The processor will want to know if the most recent I/O operation is completed or any error has occurred. · Read : Causes the I/O module to obtain an item of data from the peripheral and place it in the internal buffer. · Write : Causes the I/O module to take an item of data ( byte or word ) from the data bus and subsequently transmit the data item to the peripheral. Interrupt driven I/O The problem with programmed I/O is that the processor has to wait a long time for the I/O module of concern to be ready for either reception or transmission of data. The processor, while waiting, must repeatedly interrogate the status of the I/O module. This type of I/O operation, where the CPU constantly tests a part to see if data is available, is polling, that is, the CPU Polls (asks) the port if it has data available or if it is capable of accepting data. Polled I/O is inherently inefficient. The solution to this problem is to provide an interrupt mechanism. In this approach the processor issues an I/O command to a module and then go on to do some other useful work. The I/O module then interrupt the processor to request service when it is ready to exchange data with the processor. The processor then executes the data transfer. Once the data transfer is over, the processor then resumes its former processing. Let us consider how it works A. From the point of view of the I/O module:
B. From the processor point of view; the action for an input is as follows: : · The processor issues a READ command. · It then does something else · At the end of each instruction cycle, the processor checks for interrupts · When the interrupt from an I/O module occurs, the processor
saves the context · In this case, the processor reads the word of data from the I/O module and stores it in memory. · It then restores the context of the program it was working on and resumes execution. Interrupt Processing The occurrence of an interrupt triggers a number of events, both in the processor hardware and in software. When an I/O device completes an I/O operation, the following sequences of hardware events occurs:
Once the program counter has been loaded, the processor proceeds to the next instruction cycle, which begins with an interrupt fetch. The control will transfer to interrupt handler routine for the current interrupt. The following operations are performed at this point.
Design Issues for Interrupt Two design issues arise in implementing interrupt I/O.
Device Identification Four general categories of techniques are in common use:
Multiple Interrupts Lines: The most straight forward approach is to provide multiple interrupt lines between the processor and the I/O modules. It is impractical to dedicate more than a few bus lines or processor pins to interrupt lines. Thus, though multiple interrupt lines are used, it is most likely that each line will have multiple I/O modules attached to it. Thus one of the other three techniques must be used on each line. Software Poll : When the processor detects an interrupt, it branches to an interrupt service routine whose job is to poll each I/O module to determine which module caused the interrupt. The poll could be implemented with the help of a separate command line (e.g. TEST I/O). In this case, the processor raises TEST I/O and place the address of a particular I/O module on the address lines. The I/O module responds positively if it set the interrupt. Alternatively, each I/O module could contain an addressable status register. The processor then reads the status register of each I/O module to identify the interrupting module. Once the correct module is identified, the processor branches to a device service routine specific to that device. The main disadvantage of software poll is that it is time consuming. Processor has to check the status of each I/O module and in the worst case it is equal to the number of I/O modules.Daisy Chain : In this method for interrupts all I/O modules share a common interrupt request lines. However the interrupt acknowledge line is connected in a daisy chain fashion. When the processor senses an interrupt, it sends out an interrupt acknowledgement. The interrupt acknowledge signal propagates through a series of I/O module until it gets to a requesting module. The requesting module typically responds by placing a word on the data lines. This word is referred to as a vector and is either the address of the I/O module or some other unique identification. In either case, the processor uses the vector as a pointer to the appropriate device service routine. This avoids the need to execute a general interrupt service routine first. This technique is referred to as a vectored interrupt. The daisy chain arrangement is shown in the Figure 6.7.
Bus Arbitration : In bus arbitration method, an I/O module must first gain control of the bus before it can raise the interrupt request line. Thus, only one module can raise the interrupt line at a time. When the processor detects the interrupt, it responds on the interrupt acknowledge line. The requesting module then places it vector on the data line. Handling multiple interrupts There are several techniques to identify the requesting I/O module. These techniques also provide a way of assigning priorities when more than one device is requesting interrupt service. With multiple lines, the processor just picks the interrupt line with highest priority. During the processor design phase itself priorities may be assigned to each interrupt lines. With software polling, the order in which modules are polled determines their priority. In case of daisy chain configuration, the priority of a module is determined by the position of the module in the daisy chain. The module nearer to the processor in the chain has got higher priority, because this is the first module to receive the acknowledge signal that is generated by the processor. In case of bus arbitration method, more than one module may need control of the bus. Since only one module at a time can successfully transmit over the bus, some method of arbitration is needed. The various methods can be classified into two group – centralized and distributed. In a centralized scheme, a single hardware device, referred to as a bus controller or arbiter is responsible for allocating time on the bus. The device may be a separate module or part of the processor. In distributed scheme, there is no central controller. Rather, each module contains access control logic and the modules act together to share the bus.
Interrupt Nesting The arrival of an interrupt request from an external device causes the processor to suspend the execution of one program and starts the execution of another. The execution of this another program is nothing but the interrupt service routine for that specified device. Interrupt may arrive at any time. So during the execution of an interrupt service routine, another interrupt may arrive. This kind of interrupts are known as nesting of interrupt. Whether interrupt nesting is allowed or not? This is a design issue. Generally nesting of interrupt is allowed, but with some restrictions. The common notion is that a high priority device may interrupt a low priority device, but not the vice-versa. To accomodate such type of restrictions, all computer provide the programmer with the ability to enable and disable such interruptions at various time during program execution. The processor provides some instructions to enable the interrupt and disable the interrupt. If interrupt is disabled, the CPU will not respond to any interrupt signal. On the other hand, when multiple lines are used for interrupt and priorities are assigned to these lines, then the interrupt received in a low priority line will not be served if an interrupt routine is in execution for a high priority device. After completion of the interrupt service routine of high priority devices, processor will respond to the interrupt request of low priority devices. Direct Memory Access We have discussed the data transfer between the processor and I/O devices. We have discussed two different approaches namely programmed I/O and Interrupt-driven I/O. Both the methods require the active intervention of the processor to transfer data between memory and the I/O module, and any data transfer must transverse a path through the processor. Thus both these forms of I/O suffer from two inherent drawbacks.
To transfer large block of data at high speed, a special control unit may be provided to allow transfer of a block of data directly between an external device and the main memory, without continuous intervention by the processor. This approach is called direct memory access or DMA. DMA transfers are performed by a control circuit associated with the I/O device and this circuit is referred as DMA controller. The DMA controller allows direct data transfer between the device and the main memory without involving the processor.
When the processor wishes to read or write a block of data, it issues a command to the DMA module, by sending to the DMA module the following information.
The processor then continues with other works. It has delegated this I/O operation to the DMA module. The DMA module checks the status of the I/O devise whose address is communicated to DMA controller by the processor. If the specified I/O devise is ready for data transfer, then DMA module generates the DMA request to the processor. Then the processor indicates the release of the system bus through DMA acknowledge. The DMA module transfers the entire block of data, one word at a time, directly to or from memory, without going through the processor. When the transfer is completed, the DMA module sends an interrupt signal to the processor. After receiving the interrupt signal, processor takes over the system bus.
When the processor is suspended, then the DMA module transfer one word and return control to the processor. Note that, this is not an interrupt, the processor does not save a context and do something else. Rather, the processor pauses for one bus cycle. During that time processor may perform some other task which does not involve the system bus. In the worst situation processor will wait for some time, till the DMA releases the bus. The net effect is that the processor will go slow. But the net effect is the enhancement of performance, because for a multiple word I/O transfer, DMA is far more efficient than interrupt driven or programmed I/O. The DMA mechanism can be configured in different ways. The most common amongst them are:
Single bus, detached DMA - I/O configuration In this organization all modules share the same system bus.The DMA module here acts as a surrogate processor. This method uses programmed I/O to exchange data between memory and an I/O module through the DMA module. For each transfer it uses the bus twice. The first one is when transferring the data between I/O and DMA and the second one is when transferring the data between DMA and memory. Since the bus is used twice while transferring data, so the bus will be suspended twice. The transfer consumes two bus cycle. The interconnection organization is shown in the Figure 6.11. Figure 6.11: Single bus arrangement for DMA transfer Single bus, Integrated DMA - I/O configuration By integrating the DMA and I/O function the number of required bus cycle can be reduced. In this configuration, the DMA module and one or more I/O modules are integrated together in such a way that the system bus is not involved. In this case DMA logic may actually be a part of an I/O module, or it may be a separate module that controls one or more I/O modules. The DMA module, processor and the memory module are connected through the system bus. In this configuration each transfer will use the system bus only once and so the processor is suspended only once. The system bus is not involved when transferring data between DMA and I/O device, so processor is not suspended.
Processor is suspended when data is transferred between DMA and memory. Figure 6.12: Single bus integrated DMA transfer Using separate I/O bus In this configuration the I/O modules are connected to the DMA through another I/O bus. In this case the DMA module is reduced to one. Figure 6.13: Seperate I/O bus for DMA transfer How does the CPU communicate with I O devices?An I/O interface is required whenever the I/O device is driven by a processor. Typically a CPU communicates with devices via a bus. The interface must have the necessary logic to interpret the device address generated by the processor.
What are the types of I O mapping?Isolated and Memory Mapped 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.
What is I O structure in operating system?I/O Structure consists of Programmed I/O, Interrupt driven I/O, DMS, CPU, Memory, External devices, these are all connected with the help of Peripheral I/O Buses and General I/O Buses.
What is the difference between isolated IO and memory mapped I O?Have common bus (data, address, and control) for I/O and memory.
...
Differences between memory mapped I/O and isolated I/O –. |