Pages

Sunday, October 30, 2011

Direct Memory Access



Direct Memory Access


Interrupt-driven I/O, though more efficient than simple programmed I/O, still requires the active intervention of the processor to transfer data between memory and an I/O module, and any data transfer must traverse a path through the processor. Thus both of these forms of I/O suffer from two inherent drawbacks:
1.        The I/O transfer rate is limited by the speed with which the processor can test and service a device.
2.        The processor is tied up in managing an I/O transfer; a number of instructions must be executed for each I/O transfer.
When large volumes of data are to be moved, a more efficient technique is required: direct memory access (DMA). The DMA function can be performed by a separate module on the system bus or it can be incorporated into an I/O module. In either case, the technique works as follows.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:
Ø  Whether a read or write is requested
Ø  The address of the I/O device involved
Ø  The starting location in memory to read data from or write data to
Ø  The number of words to be read or written
The processor then continues with other work. It has delegated this I/O operation to the DMA module, and that module will take care of it. 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 complete, the DMA module sends an interrupt signal to the processor.
The DMA module needs to take control of the bus to transfer data to and from memory. Because of this competition for bus usage, there may be times when the processor needs the bus and must wait for the DMA module. 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 (the time it takes to transfer one word across the bus). The overall effect is to cause the processor to execute more slowly during a DMA transfer when processor access to the bus is required. Nevertheless, for a multiple-word I/O transfer, DMA is far more efficient than interrupt driven or programmed I/O.


Saturday, October 29, 2011

Interrupt-Driven I/O


Interrupt-Driven I/O

With programmed I/O, the processor has to wait a long time for the I/O module of concern to be ready for either reception or transmission of more data. The processor,while waiting,must repeatedly interrogate the status of the I/O module.As a result, the performance level of the entire system is severely degraded.
An alternative is for the processor to issue an I/O command to a module and then go on to do some other useful work.The I/O module will then interrupt the processor to request service when it is ready to exchange data with the processor.The processor then executes the data transfer, as before, and then resumes its former processing.
Let us consider how this works, first from the point of view of the I/O module. For input, the I/O module receives a READ command from the processor. The I/O module then proceeds to read data in from an associated peripheral. Once the data are in the module’s data register, the module signals an interrupt to the processor over a control line. The module then waits until its data are requested by the processor. When the request is made, the module places its data on the data bus and is then ready for another I/O operation.
From the processor’s point of view, the action for input is as follows. The processor issues a READ command. It then saves the context (e. g., program counter and processor registers) of the current program and goes off and does something else (e. g., the processor may be working on several different programs at the same time).At the end of each instruction cycle, the processor checks for interrupts. When the interrupt from the I/O module occurs, the processor saves the context of the program it is currently executing and begins to execute an interrupt-handling program that processes the interrupt. 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 that had issued the I/O command (or some other program) and resumes execution.

shows the use of interrupt-driven I/O for reading in a block of data. Interrupt-driven I/O is more efficient than programmed I/O because it eliminates needless waiting.However, interrupt-driven I/O still consumes a lot of processor time, because every word of data that goes from memory to I/O module or from I/O module to memory must pass through the processor.
Almost invariably, there will be multiple I/O modules in a computer system, so mechanisms are needed to enable the processor to determine which device caused the interrupt and to decide, in the case of multiple interrupts, which one to handle first. In some systems, there are multiple interrupt lines, so that each I/O module signals on a different line. Each line will have a different priority.Alternatively, there can be a single interrupt line, but additional lines are used to hold a device address. Again, different devices are assigned different priorities.

PROCESSOR REGISTERS


PROCESSOR REGISTERS

A processor includes a set of registers that provide memory that is faster and smaller than main memory. Processor registers serve two functions:
Ø  User-visible registers: Enable the machine or assembly language programmer to minimize main memory references by optimizing register use. For high-level languages, an optimizing compiler will attempt to make intelligent choices of which variables to assign to registers and which to main memory locations. Some high-level languages, such as C, allow the programmer to suggest to the compiler which variables should be held in registers.
Ø  Control and status registers: Used by the processor to control the operation of the processor and by privileged OS routines to control the execution of programs.
There is not a clean separation of registers into these two categories. For example, on some processors, the program counter is user visible, but on many it is not. For purposes of the following discussion, however, it is convenient to use these categories.
User-Visible Registers
A user-visible register may be referenced by means of the machine language that the processor executes and is generally available to all programs, including application programs as well as system programs. Types of registers that are typically available are data, address, and condition code registers.
Data registers can be assigned to a variety of functions by the programmer. In some cases, they are general purpose in nature and can be used with any machine instruction that performs operations on data. Often, however, there are restrictions. For example, there may be dedicated registers for floating-point operations and others for integer operations.
Address registers contain main memory addresses of data and instructions, or they contain a portion of the address that is used in the calculation of the complete or effective address. These registers may themselves be general purpose, or may be devoted to a particular way, or mode, of addressing memory. Examples include the following:
Ø  Index register: Indexed addressing is a common mode of addressing that involves adding an index to a base value to get the effective address.
Ø  Segment pointer: With segmented addressing,memory is divided into segments, which are variable-length blocks of words. A memory reference consists of a reference to a particular segment and an offset within the segment; this mode of addressing is important in our discussion of memory management. In this mode of addressing, a register is used to hold the base address (starting location) of the segment. There may be multiple registers; for example, one for the OS (i.e., when OS code is executing on the processor) and one for the currently executing application.
Ø  Stack pointer: If there is user-visible stack2 addressing, then there is a dedicated register that points to the top of the stack.This allows the use of instructions that contain no address field, such as push and pop.
For some processors, a procedure call will result in automatic saving of all user visible registers, to be restored on return. Saving and restoring is performed by the processor as part of the execution of the call and return instructions.This allows each procedure to use these registers independently. On other processors, the programmer must save the contents of the relevant user-visible registers prior to a procedure call, by including instructions for this purpose in the program. Thus, the saving and restoring functions may be performed in either hardware or software, depending on the processor.

Friday, October 28, 2011

The Operating System as a User/Computer Interface


The Operating System as a User/Computer Interface

The hardware and software used in providing applications to a user can be viewed in a layered or hierarchical fashion, as depicted in Figure 1.The user of those applications, the end user, generally is not concerned with the details of computer hardware. Thus, the end user views a computer system in terms of a set of applications.An application can be expressed in a programming language and is developed by an application  programmer. If  one  were  to  develop  an  application  program  as  a  set  of machine  instructions  that  is  completely  responsible  for  controlling  the  computer hardware, one would be faced with an overwhelmingly complex undertaking.To ease this chore, a set of system programs is provided. Some of these programs are referred to as utilities.These implement frequently used functions that assist in program creation, the management of  files, and  the control of  I/O devices. A programmer will make use of these facilities in developing an application, and the application,while it is running, will invoke the utilities to perform certain functions. The most important collection of  system programs  comprises  the OS. The OS masks  the details of  the hardware from the programmer and provides the programmer with a convenient interface for using the system. It acts as mediator,making it easier for the programmer and for application programs to access and use those facilities and services.

Briefly, the OS typically provides services in the following areas:
Ø Program  development: The OS  provides  a  variety  of  facilities  and  services, such as editors and debuggers, to assist the programmer in creating programs. Typically, these  services  are  in  the  form  of  utility  programs  that, while  not
Figure 1 

strictly part of the core of the OS, are supplied with the OS and are referred to as application program development tools.
Ø Program  execution: A  number  of  steps  need  to  be  performed  to  execute  a program. Instructions and data must be loaded into main memory, I/O devices and  files must be  initialized, and other  resources must be prepared. The OS handles these scheduling duties for the user.
Ø Access to I/O devices: Each I/O device requires its own peculiar set of instructions or control signals for operation.The OS provides a uniform interface that hides these details so that programmers can access such devices using simple reads and writes.
Ø Controlled access to files: For file access, the OS must reflect a detailed understanding of not only the nature of the I/O device (disk drive, tape drive) but also the structure of the data contained in the files on the storage medium. In the case of a system with multiple users, the OS may provide protection mechanisms to control access to the files.
Ø System access: For shared or public systems, the OS controls access to the system as a whole and to specific system resources.The access function must provide  protection  of  resources  and  data  from  unauthorized  users  and  must resolve conflicts for resource contention.
Ø Error detection and response: A variety of errors can occur while a computer system is running.These include internal and external hardware errors, such as a  memory  error, or  a  device  failure  or  malfunction; and  various  software errors, such as division by zero, attempt to access forbidden memory location, and inability of the OS to grant the request of an application. In each case, the OS must provide a response that clears the error condition with the least impact on  running applications. The  response may  range  from ending  the program that caused the error, to retrying the operation, to simply reporting the error to the application.
Ø Accounting: A good OS will collect usage statistics for various resources and monitor performance parameters such as response time. On any system, this information is useful in anticipating the need for future enhancements and in tuning the system to improve performance. On a multiuser system, the information can be used for billing purposes.

Basic Elements of Computer System


BASIC ELEMENTS OF COMPUTER SYSTEM

At a top level, a computer consists of processor,memory, and I/O components, with one or more modules of each type. These components are interconnected in some fashion to achieve the main function of the computer, which is to execute programs.
Thus, there are four main structural elements:

Ø  Processor: Controls the operation of the computer and performs its data processing functions.When there is only one processor, it is often referred to as the central processing unit (CPU).
Ø  Main memory: Stores data and programs. This memory is typically volatile that is, when the computer is shut down, the contents of the memory are lost. In contrast, the contents of disk memory are retained even when the computer system is shut down.Main memory is also referred to as real memory or primary memory.
Ø  I/O modules: Move data between the computer and its external environment. The external environment consists of a variety of devices, including secondary memory devices (e. g., disks), communications equipment, and terminals.
Ø  System bus: Provides for communication among processors, main memory, and I/O modules.

Figure 1.1 depicts these top-level components. One of the processor’s functions is to exchange data with memory. For this purpose, it typically makes use of two internal (to the processor) registers: a memory address register (MAR), which specifies the address in memory for the next read or write; and a memory buffer register (MBR), which contains the data to be written into memory or which receives the data read from memory. Similarly, an I/O address register (I/OAR) specifies a particular I/O device. An I/O buffer register (I/OBR) is used for the exchange of data between an I/O module and the processor.
       
         A memory module consists of a set of locations, defined by sequentially numbered addresses. Each location contains a bit pattern that can be interpreted as either an instruction or data.An I/O module transfers data from external devices to processor and memory, and vice versa. It contains internal buffers for temporarily holding data until they can be sent on.


Related Post