Click here to load reader

2 memory system

Embed Size (px)

Citation preview

1. The Memory System By: Priyanka Mehta (Assist. Prof. CS(SU)) 2. Memory hierarchy... The memory unit is an essential component in any digital computer since it is needed for storing programs and data Most general-purpose computers would run more efficiently if they were equipped with additional storage beyond the capacity of the main memory. Also, there is not just enough space in one memory unit to accommodate all the programs used in a typical computer. Moreover, most computer users accumulate and continue to accumulate large amounts of data processing softwares. Not all accumulated information is needed by the processor at the same time. Therefore, it is more economical to use low-storage devices to backup for storing the information that is not currently used by the CPU. 3. Continued... The memory hierarchy system consists of all storage devices employed in a computer system from the slow but high- capacity auxiliary memory to a relatively faster main memory, to an even smaller and faster cache memory accessible to high speed processing logic. Magnetic tapes Magnetic disks I/O processor Main memory Cache memory CPUAuxiliary memory 4. Continued... Main memory: The memory unit that communicates directly with the CPU is called the main memory. Thus, only the programs and data currently needed by the processor reside in the main memory. Auxiliary memory: Devices that provide backup storage are called auxiliary memory. The most common auxiliary memory devices used in the computer systems are magnetic disks and tapes. They are used to store system programs, large data files and other backup information. The information stored in the auxiliary memory are transferred to the main memory when needed. 5. Continued... Cache memory: A special very high speed memory called cache is sometimes used to increase the speed of processing by making current programs and data available to the CPU at a rapid rate. The cache memory is employed in the computer systems to compensate for the speed differential between main memory access time and processor logic. CPU logic is usually faster than main memory access time, with the result that the processing speed is limited primarily by the speed of the main memory. A technique used to compensate for the mismatch in operating speeds is to employ an extremely fast, small cache between the CPU and main memory whose access time is close to processor logic clock cycle time. The cache is used for storing the segments of programs currently being executed in the CPU and temporary data frequently needed in the calculations. Hence, by making programs and data available at a rapid rate, it is possible to increase the performance rate of the computer. 6. Registers in CPU Cache (SRAM) Main memory (DRAM) Disk storage Tape units Level 0 Level 1 Level 2 Level 3 Level 4 Capacity Increases in cost per bit Increases in Capacity and Access time 7. Main memory... The main memory is the central storage unit in a computer system. It is relatively large and fast memory, used to store programs and data during the computer operations. The principle technology used for the main memory is based on semiconductor integrated circuits. Integrated circuit RAM chips are available in two possible operating modes, static and dynamic: Static RAM(SRAM): It consists essentially of internal flip-flops that store the binary information. The stored information remains valid as long as power is applied to the unit. The static RAM is easier to use and has shorter read and write cycles. They are used for implementing the cache memory. Dynamic RAM(DRAM): It stores the binary information in the form of electric charges that are applied to the capacitors. The stored charge in the capacitors tend to discharge with time and the capacitors must be periodically recharged by refreshing the dynamic memory. The dynamic RAM offers reduced power consumption and larger storage capacity in a single memory chip. They are used for implementing the main memory. 8. Continued... ROM: Most of the main memory in a general-purpose computer is made up of RAM integrated circuit chips, but a portion of the memory may be constructed with ROM chips. ROM is used to store programs that are permanently resident in the computer and for tables of constants that do not change in value once the production of the computer is completed. Also, the ROM portion of main memory is needed for storing an initial program, called a bootstrap loader. The bootstrap loader is a program whose function is to start the computers operating system when power is turned ON. Since RAM is volatile, its contents are destroyed when power is turned OFF. However, the contents of the ROM remain unchanged after power is turned OFF and ON again. 9. Typical RAM Chip... CS1 CS2 RD 1288 RAM WR AD7 Chip select 1 Chip select 2 Read Write 7-bit address 8-bit data bus The capacity of the memory is 128 words of eight bits per word. It requires a 7-bit address and an 8-bit bi-directional data bus allows the transfer of data either from memory to CPU during a read operation, or from CPU to memory during a write operation. The read and write inputs specify the memory operation and the two chips select (CS) control inputs are for enabling the chip only when it is selected by the microprocessor. 10. Continue... The unit is in operation only when CS1 =1 and CS2=0. If the chip select inputs are not enabled, or if they are enabled, but the read or write inputs are not enabled, the memory is inhibited and its data bus is in a high-impedance state. When CS1 = 1 and CS2 = 0, the memory can be placed in a write or read mode. When the WR input is enabled , the memory stores a byte from the data bus into a location specified by the address input lines. When the RD input is enabled , the content of the selected byte is placed into the data bus. CS1 CS2 RD WR Memory function State of data bus 0 0 Inhibit High-impedance 0 1 Inhibit High-impedance 1 0 0 0 Inhibit High-impedance 1 0 0 1 Write Input data to RAM 1 0 1 Read Output data from RAM 1 1 Inhibit High-impedance 11. Typical ROM Chip... CS1 CS2 5128 ROM AD9 Chip select 1 Chip select 2 9-bit address 8-bit data bus Since a ROM can only read, the data bus can only be in an output mode. For the same size chip, it is possible to have more bits of ROM than RAM, because the internal binary cells in ROM occupy less space than in RAM. For this reason, the diagram specifies a 512-byte ROM, while the RAM has only 128 bytes. The 9-bit address lines in ROM chip specify any one of the 512 bytes stored in it. The two chip select input must be CS1=1 and CS2=0 for the unit to operate. Otherwise, the data-bus is in a high-impedance state. Also, there is no need of read and write control because the unit can only read. Thus, when the chip is enabled by the two select inputs, the byte selected by the address lines appears on the data-bus. 12. Cache Memory... Analysis of large number of typical programs has shown that the references to memory at any given interval of time tend to be confined within a few localized areas in memory. This phenomenon is known as the property of locality of reference. When a program loop is executed or a subroutine is called, the CPU repeatedly refers to the set of instructions in memory that constitute a loop or fetch the set of instructions from the memory. Thus, loops and memory tends to localize the references to memory for fetching instructions. The result of these observations is the locality of reference, which states that over a short interval of time, the addresses generated by a typical program refer to a few localized areas of memory repeatedly, while the remainder of memory is accessed infrequently. Hence, if the active portions of the program and data are placed in a fast small memory, the average memory access time is reduced, thus reducing the total execution time of the program. Such a fast and small memory is referred to as a cache memory, which is placed between the CPU and the main memory. 13. Basic operation of cache... When the CPU needs to access memory , the cache is examined. If the word is found in the cache, it is read from the fast memory. If the word addressed by the CPU is not found in the cache, the main memory is accessed to read the word. A block of words containing the one just accessed is then transferred from the main memory to cache memory. In this manner, some data are transferred to cache so that future references to memory find the required words in the fast cache memory. 14. Performance of cache... The performance of cache memory is frequently measured in terms of a quantity called hit-ratio. When the CPU refers the memory and finds the word in cache, it is said to produce a hit. If the word is not found in the cache, it is in the main memory and it counts as a miss. Thus, the ratio of the number of hits divided by the total CPU memory references to memory (hits plus misses) is the hit ratio. If the hit ratio is high enough so that most of the time the CPU accesses the cache instead of main memory, the average access time is closer to the access time of the fast cache memory. 15. Auxiliary Memory... The operating speed of the main memory should be as fast as possible to cope up with the CPU speed. These high speed storage devices are very expensive and hence the cost per bit of storage is also very high. Also, the storage capacity of the main memory is also very limited. Therefore, additional memory is required in all the computer systems to store hundreds of bytes of data for the CPU to process. This memory is called auxiliary memory or secondary memory. 16. Storage Devices: Magnetic Tapes Magnetic Tapes: It consist of magnetic materials that store data permanently. It can be 12.5mm to 25mm wide plastic film-type and 500m to 1200m long which is coated with the magnetic material. The deck is connected to the processor and information is fed into or read from the tape through the processor. It is similar to cassette tape recorder. Magnetic tapes are used for large computers like mainframe computers where large volume of data is stored for a longer time. The cost of storing the data in tape is inexpensive. 17. Continued... 18. Continued... Advantages: Compact: A 10-inch diameter reel of tape is 2400 feet long and is able to hold 800, 1600 or 6250 characters in each inch of its length. The maximum capacity of such tape is 180 million characters. Thus, data are stored much more compactly on tape. Economical: The cost of storing characters is very less as compared to other storage devices. Fast: Copying of data is easier and faster. Long-term storage and Reusability: They can be used for long term storage and tape can be used repeatedly without loss of data. 19. Storage Devices: Magnetic Disks Magnetic Disks: It is a circular disk coated with magnetic material. Each disk consist of a number of invisible concentric circles called tracks. Information is recorded on tracks of a disk surface in the form of tiny magnetic spots. The presence of a magnetic spot represents one bit and its absence represents zero bit. The information stored on the disk can be read many a times without affecting the stored data. However, writing new data erases existing data from the disk. 20. Continued... Track: A disk drive track is a circular path on the surface of a disk on which the information is magnetically recorded and from which recorded information is read. Geometrical Sector: Tracks are subdivided into blocks called sectors. Each sector stores a fixed amount of data, traditionally 512 bytes for hard drives and 2048 bytes for CD-ROMs and DVD- ROMs. Newer hard drives use 4096 byte (4kb) sectors. Cluster: A cluster is the smallest logical amount of disk space that can be allocated to hold a file. Typical cluster sizes range from 1 sector to 128 sectors. A cluster need not be physically a contiguous on the disk, it may span more than one track or, if sector interleaving is used, may even be discontiguous within a track. 21. Continued... Hard Disk: A hard disk drive (HDD) is a data storage device used for storing and retrieving digital information using rapidly rotating disks (platters) coated with magnetic material. An HDD retains its data even when powered off. Data is read in a random-access manner, meaning individual blocks can be stored or retrieved in any order rather than sequentially. The two most common form of a modern HDDs are: 3.5 inch HDD in desktop computers 2.5 inch HDD in laptops 22. Continued... Floppy Disk: A floppy disk is a disk storage medium composed of a disk of thin and flexible magnetic storage medium, sealed in a rectangular plastic carrier lined with fabric that removes dust particles. They are read written by a floppy disk drive (FDD). Floppy disks, initially as 8 inch media and later in 5.25- inch and 3.5-inch sizes, were a ubiquitous form of data storage. 23. Storage Devices: Optical Disks Optical Disks: An optical disk is a flat, usually circular disc which encodes binary data on a special material (often aluminium) on one of its flat surfaces. The data is stored on the disc with a laser or stamping machine, and can be accessed when the data path is illuminated with a laser diode in an optical disc drive which spins the disc at speeds of about 200 to 4000 RPM or more, depending on the drive type, disc format and the distance of the read head from the center of the disk. Unlike the 3.5-inch floppy disk, most optical discs do not have an integrated protective casing and are therefore susceptible to data transfer problems due to scratches, fingerprints and other environmental problems. Optical discs are usually between 7.6 and 30cm in diameter, with 12cm being the most common size. An optical disc is designed to support one of three recording types: read-only (CD and CD-ROM), recordable (write-once CD-R) or re-recordable (rewritable CD-RW). 24. Virtual Memory... The main memory is considered as a physical memory in which many programs wants to reside. However, due to the limited size of the physical memory, all the programs cannot be loaded into it simultaneously. To solve this problem, the concept of virtual memory is used that permit the user to construct programs as though a large memory space were available, equal to the totality of auxiliary. Each address that is referenced by the CPU goes through an address mapping from the so-called virtual address to a physical address in main memory. The translation or mapping is handled automatically by the hardware by means of mapping table. Virtual memory is used to give programmers the illusion that they have a very large memory at their disposal, even though the computer actually has a relatively small main memory. 25. Address space and memory space... Address space: An address used by the programmer is called a virtual address. And the set of such addresses are called address space. Thus, the address space is the set of addresses generated by programs as they reference instructions and data. Memory space: An address in the main memory is identified by a unique address called physical address. The set of such locations is called the memory space. Thus, memory space consists of the actual main memory locations directly addressable for processing. 26. Relation between address space & memory space... In a multi-program computer system, programs and data are transferred to and from auxiliary memory and main memory based on demands imposed by the CPU. Suppose that Program1 is currently being executed in the CPU. Program1 and a portion of the associated data are moved from the auxiliary memory into main memory. Portions of program and data need to be in contiguous locations in memory since information is being moved in and out, and empty spaces may be available in scattered locations in memory. Program 1 Data 1,1 Data 1,2 Program 2 Data 2,1 Program 1 Data 1,1 Memory space Address space 27. Continued... In the virtual memory system, programmers are told that they have the total address space at their disposal. Consider an example, where the address field of an instruction code consist of 20 bits but physical memory addresses must be specified with only 15 bits. Thus, CPU will reference instructions and data with a 20 bit address, but the information at this address must be taken from physical memory because access to auxiliary storage for individual words will be prohibitively long. Hence, a table is needed to map a virtual address of 20 bits to a physical address of 15 bits. This mapping is a dynamic operation, which means that every address is translated immediately as a word is referenced by CPU.