Sunteți pe pagina 1din 4

Computer System Operation Basics

To better understand the design issues of operating systems, it is best to have knowledge or at least be familiar with the hardware of a computer system.

Computer Hardware Components


The figure below shows a simplified block diagram of a computer system.

There are four basic components of a computer system: CPU, main memory, secondary memory, and I/O devices. An interconnecting bus or system bus serves as the communication link between these four components. The CPU The CPU is the computing part of the computer and is responsible for program execution and coordination of other system components. The CPU fetches data from the main memory then decodes it. After decoding, the instruction will be executed. This process is called fetch-decode-execute cycle and is repeated for each succeeding instruction. The main memory is much slower compared to the CPU. Because of this, fetching instructions and data from the main memory slows down the CPU. To minimize these effects, the internal registers of the CPU are used for frequently used data. The data or operands are placed in the CPU s registers which results to faster execution of the instructions. The registers are generally 10 to 100 times faster than the main memory. The CPU contains a special register called program counter (PC). It keeps track of the main memory address of the instruction that will be executed next. When a program is loaded in main memory, the 1 OPERSYS | Operating System

instructions are placed in sequential memory locations. For example, an instruction at memory location 400 is currently executing. The program counter will be 401 which is the next memory address. If the CPU fetches the instruction at memory location 401, the program counter will then be updated to 402. This process goes on until a branch or jump instruction occurs or program execution terminates.

The Primary and Secondary Memory The main memory is a volatile memory where programs and their data are placed during execution. When the power is turned off, it loses its contents. All programs and data can be stored permanently in secondary memory (auxiliary memory). The operating system locates the program from a secondary storage and then copies it to the main memory before it can be executed. Examples of secondary storage devices are: Hard disks, floppy disks, CD-ROMs, DVD-ROMs, etc.

The I/O Devices I/O devices provide input and/or output capabilities and are considered the slowest components in a computer system. Examples of input devices are keyboards, mouse, scanners, joystick, game pads, etc. Examples of output devices are printers, plotters, monitors, speakers, etc. Secondary storage devices are also considered as I/O devices. This is because the CPU has to pass through the channels of I/O devices to be able to access the secondary memory. The only component that the CPU accesses directly is the main memory.

OPERSYS | Operating System

Interrupts
The CPU becomes inefficient when it communicates with slower I/O devices. Read the following scenario. a. A user wants to print a file. b. The first batch of characters will be sent by the CPU to the printer. Assume that the printer has a small buffer memory. c. The CPU checks continuously and waits until the printer finishes before it can send the next batch. If the printer takes 10 seconds to print a batch of characters, then the CPU will have to check and wait for 10 seconds. This time spent by the CPU could have been used more efficiently. This process of handling I/O devices is called polling. d. Multitasking is used as a solution to this problem. The CPU is scheduled by the operating system to execute another program instead of waiting for the printer to finish. This method maximizes CPU utilization but a new problem is created. If the printer finishes printing, the CPU will not know since it is busy executing another program. This will make the printing job wait for an indefinite amount of time. As a solution, computer systems and operating systems were designed to be interrupt-driven. Interrupts are signals sent by the devices and programs which are used to get the attention of the CPU and the operating system. In the printer scenario, if the printer finishes printing and is ready to receive the next batch, it will send an interrupt signal to the CPU. The CPU stops whatever it is executing and sends another batch of characters to the printer. I/O devices are usually the ones making interrupt requests, which are referred to as hardware interrupts. Software also generates exceptions. Traps are usually used to inform the operating interrupt requests in the form of traps or system when an error occurs and when operating system services are needed. When an interrupt request is generated, the CPU will stop executing the current program and start executing the interrupt service routine (ISR) of the device that made the interrupt request. Each device has its own ISR which is usually a part of their respective device drivers. It instructs the CPU on how to handle to a particular interrupt request. The figure below illustrates how the CPU handles interrupt requests.

OPERSYS | Operating System

Normally, these sequence of events happen when an interrupt request is made: 1. The CPU is currently processing or executing a program. Assume that the current instruction is at memory location 500. 2. An I/O device sends an interrupt signal. Assume that the device is the printer. 3. The printer should wait until the CPU finishes executing the current instruction. 4. The latest values of the registers it is using should be saved in the main memory by the CPU before it responds to the ISR. This is important since the same registers might be used by the ISR. 5. The CPU proceeds to execute the ISR of the printer. 6. After the CPU finishes executing the ISR, it will restore the values of the registers of the previous program. It will start executing at memory location 501.

OPERSYS | Operating System

S-ar putea să vă placă și