Have skipped some sections related to introduction/basics of CPU, CU, Registers, Interrupt etc. Might post them here sometime later.
Program Interrupt refers to the transfer of program control from a currently running program to another subroutine as a consequence of an external or internal request.
After a program has been interrupted and the service routine has been executed, the processor must return to exactly the same state that it was in, when the interrupt occured.
Types of Interrupts
- External Interrupts
- Internal Interrupts
- Software Interrupts
External interrupts come from I/O devices, from a timing device, from a circuit monitoring the power supply, or from any other external source. Timeout interrupt may result from a program that is in an endless loop and has exceeded the time allocated to it.
Internal Interrupts arise due to erroneous or illegal use of an instruction or data. Internal interrupts are also called ‘traps’. For example, register overflow, attempt to divided by zero, stack overflow etc.
The difference between internal and external interrupts is that the internal interrupt is initiated by some exceptional condition caused by program itself rather than by an external event. Internal interrupts are synchronous with the program while external interrupts are asynchronous. External/internal interrupts are initiated in hardware of CPU. A software interrupt is initiated by executing an instruction. Software interrupt is a special call instruction that behaves like an interrupt rather than a call.
No matter how fast the processor is, the processing speed depends more on the speed of the main memory and other Input/Output devices. It is because of this reason that a cache memory having access time closer to the processor speed is introduced.
Memory is an essential component of a digital computer. It is a storing device. It stores programs, data, results etc. At present the following two kinds of memory are commonly used in modern computers.
- Semiconductor memory
- Magnetic memory
The semiconductor memory is faster, compact and lighter. It consumes less power and is a static device, i.e. there is no rotating part in it. The magnetic memory is cheaper than static memory. It is in the form of magnetic disk or magnetic tapes. The semiconductor memory is employed as the main memory or primary memory of the computer. It stores programs and data which are currently needed by the CPU. The magnetic memory is used as semiconductor memory or auxiliary memory.
Primary Memory and Secondary Memory
The size of the main memory is comparatively much smaller than that of secondary memory. CPU communicates directly with the main memory. The speed of the main memory must match the fast speed of the CPU so semiconductor(chip) technology is used in the main memory. Random Access Memory(RAM) and Read Only Memory(ROM) ICs are used for main memory. RAMs are volatile in nature, i.e. their content gets erased when the power goes off.
The secondary memory is employed for bulk storage of programs, data and other information. The secondary storage is of a permanent nature. Magnetic memories like hard disks and floppy disks are commonly used as secondary memory. The classification of memory can now be done on the basis of primary and secondary memory.
Figure 4.4 – yet to be inserted
Capacity of Memory
In computers the capacity of memory is measured in Mega bytes. Byte is the smaller unit and means a set of 8 bits. Higher units are Kilo bytes, Mega bytes and Giga bytes.
1 character = 1byte = 8 bits
1 Kilo bytes = 1024 bytes
1 Mega bytes = 1024 KB
1Giga byte = 1024 MB
The cache memory is placed between the CPU and the main memory. It is a fast speed memory and is expensive and faster than the main memory.
Cache memory is used to store the frequently accessed data of the main memory. The instructions that are frequently used are stored in the cache memory. It is used to reduce the average access time for address, instructions or data which are normally stored in the main memory. Thus the cache memory increases the operating speed of the system. But it is much costlier than main memory. From economic consideration, the capacity of the cache memory is much less as compared to main memory.
Fig. 4.5 – skipped, yet to be uploaded
Most of the 32-bit(or better) microprocessors have cache memory on the chip. Besides the modern computers also provide external cache on the motherboard. The technique to access cache memory is different from that of accessing the main memory. When CPU accesses the main memory, it outputs the data contained at that specified address. The cache memory first compares the incoming address to the address stored with the data in cache – if it matches it is said that a ‘hit’ has occurred and corresponding data is read from the cache memory. In case the address does not match then it is said that a ‘miss’ has occurred and the data is read from the main memory by the CPU which also gets stored in cache memory simultaneously, so that when the same address is accessed next time, a hit may occur.
RAM (Random Access Memory)
RAM stands for Random Access Memory and is a read-write memory of the computer. In RAM any location can be accessed in a random manner and the access time is same for each memory location.
A chip actually contains lot of memory cells within it. Each cell contains group of bits that are accessed together. The size of memory data register is equal to the number of bits stored in each of the cells. The data bus contains a number of lines equal to the size of MDR. Each memory cell is identified by a unique address. This address is placed in the memory address register to access the memory cell. The size of the address bus is equal to the number of bits in the memory address register. Two control signals are used to distinguish between memory read and memory write. It is volatile in nature. Although both RAM and ROM possess random access, the R/W memory is called RAM. There are two important types of RAM – Static RAM and Dynamic RAM.
Static RAM consists of internal flip-flops that store the binary information. The stored information in this SRAM remains valid as long as power is applied to the unit. SRAM is easier to use and has shorter read and write cycles, i.e. high speed. Static RAMs are costlier and consume more power.
It stores binary information in the form of electric charges that are applied to the capacitors. The stored charges on the capacitors tend to discharge with time. The capacitors must be periodically charged by refreshing the dynamic memory. This refreshing is done by recycling through the words every few milliseconds to restore the decaying charge. DRAM has reduced power consumption and larger storage capacity in a single memory chip.
ROM(Read Only Memory)
ROM stands for Read Only Memory, i.e. nothing can be written on it. ROM is a non-volatile memory, the information stored on it is not lost when power goes off. It is used for storing the bulk of programs that are permanent residents on the computer. The contents of ROM are decided by the hardware manufacturer of computer. The necessary programs are hardwired during the manufacture of computer. It also possess random access property and store information which is not subjected to change.
Need for ROM
ROM is used for storing an initial program called a ‘Bootstrap loader’. This is a program whose function is to start the computer software operating when power is turned on. Since RAM is volatile, its contents are destroyed when power is turned off. The contents of ROM remain unchanged after power is turned off and on again. When power is turned on, the hardware of the computer sets the program counter to the first address of the bootstrap loaded. The bootstrap program loads a portion of the operating system from disk to main memory and control is then transferred to the operating system.