Chapter 5 - Memory
5.1 Types of Memory
Random Access Memory (RAM) is read/write memory. It is volatile meaning is loses its contents when the power is removed (unlike flash). RAM is used to store programs and data while they are executing because traditionally it has much faster access speed than disk drives.
Type of RAM
|SRAM||Static Random Access Mrmory (SRAM) does not need to be refreshed to store its memory. It therefore uses less power. It requires more circuits for each memory cell making it costlier and smaller sizes.|
|DRAM||Dynamic Random Access Memory (DRAM) requires a periodic refresh since the capacitors gradually discharge energy. It requires fewer circuits for each memory cell making it cheaper and larger sizes possible.|
|SDRAM||Synchronous Dynamic Random Access Memory (SDRAM) is a dynamic random access memory that is synchronized to the clock speed on the system bus. The memory controller will therefore know the exact clock cycle when memory requests will be sent. t knows the exact clock cycle for memory requests It is capable of running at faster speeds than DRAM.|
|DDR SDRAM||Double Data Rate SDRAM doubles the speed of SDRAM by transferring data on both the rising and falling edges of the clock signal. DDR has be superseded by DDR2, DDR3, and DDR4 - each offering faster speeds.|
Read Only Memory (ROM) is used to
store programs and data permanently. A microwave oven probably stores its
program in ROM since it doesn't need to be updated. Older PC's used ROM to
store BIOS. Newer PC's store it in flash so that it can be updated.
Flash Memory was developed from EEPROM (electrically erasable programmable read only memory). It is a non-volatile memory that retains its data when power is removed. One limitation is that it has a relatively limited number of write cycles before it begins to degrade. Flash memory is generally slower than SDRAM.
5.2 Virtual Memory
Virtual memory is a memory management technique that utilizes your hard drive space as an extension of RAM. This is usually done by a system called paging and the area on the hard drive is called a page file. The operating system maps virtual addresses to physical addresses.
5.3 CPU Cache
Modern computers contain a small amount of memory to function as the CPU cache. The purpose is to keep frequently used data and programs close to the CPU's core so main memory (RAM) doesn't have to be accessed as much. When a CPU needs to read or write to memory, it first checks the cache. If the CPU doesn't find the memory location in cache, then it proceeds to main memory. The replacement policy is the logic it uses to determine what data is most likely needed in the future and what data is no longer needed and can be removed. If data is written to cache, the write policy determines when the data is written back to main memory.
Level 1 Cache (L1) is part of the CPU chip itself and therefore the fastest.
Level 2 Cache (L2) may or may not be part of the CPU chip. It's is further from the core than L1 and usually larger in size.
Level 3 Cache (L3) may be part of
the CPU chip or on the motherboard. It sits in between L2 and main memory.
It may be shared with other resources.
Below is a diagram showing the cache levels in Intel Nehalem (e.g. Core i7) microarchitecture chips. In addition, main memory and virtual memory are shown on the diagram.