Page 258 -
P. 258

7.3 / PROGRAMMED I/O 225

                  Table 7.1 I/O Techniques

                                                   No Interrupts  Use of Interrupts
                   I/O-to-memory transfer through processor  Programmed I/O  Interrupt-driven I/O
                   Direct I/O-to-memory transfer                  Direct memory access (DMA)


                  responsible for extracting data from main memory for output and storing data in
                  main memory for input. The alternative is known as direct memory access (DMA).
                  In this mode, the I/O module and main memory exchange data directly, without
                  processor involvement.
                       Table 7.1 indicates the relationship among these three techniques. In this sec-
                  tion, we explore programmed I/O. Interrupt I/O and DMA are explored in the fol-
                  lowing two sections, respectively.

                  Overview of Programmed I/O

                  When the processor is executing a program and encounters an instruction relating
                  to I/O, it executes that instruction by issuing a command to the appropriate I/O
                  module. With programmed I/O, the I/O module will perform the requested action
                  and then set the appropriate bits in the I/O status register (Figure 7.3).The I/O mod-
                  ule takes no further action to alert the processor. In particular, it does not interrupt
                  the processor.Thus, it is the responsibility of the processor periodically to check the
                  status of the I/O module until it finds that the operation is complete.
                       To explain the programmed I/O technique, we view it first from the point of
                  view of the I/O commands issued by the processor to the I/O module, and then from
                  the point of view of the I/O instructions executed by the processor.

                  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 may receive when it is addressed
                  by a processor:
                     • Control: Used to activate a peripheral and tell it what to do. For example, a
                       magnetic-tape unit may be instructed to rewind or to move forward one record.
                       These commands are tailored to the 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 that the peripheral of interest
                       is powered on and available for use. It will also want to know if the most recent
                       I/O operation is completed and if any errors occurred.
                     • Read: Causes the I/O module to obtain an item of data from the peripheral
                       and place it in an internal buffer (depicted as a data register in Figure 7.3).The
                       processor can then obtain the data item by requesting that the I/O module
                       place it on the data bus.
                     • Write: Causes the I/O module to take an item of data (byte or word) from the
                       data bus and subsequently transmit that data item to the peripheral.
   253   254   255   256   257   258   259   260   261   262   263