1.1 Concept of Computer Memory
Computer memory is the internal storage of a computer system that holds data, instructions, and processed results during data processing. It enables the system to temporarily store and process data as needed. Memory is crucial for the proper functioning of a computer, similar to how a well-organized library shelf holds books for quick access.
Key Functions of Memory:
- Data Storage: Holds binary data (0s and 1s) representing information
- Data Retrieval: Quickly accesses stored data when needed by the CPU
- Program Execution: Stores instructions that the CPU executes
- Intermediate Results: Temporarily holds results of calculations
1.2 Memory Hierarchy
Memory hierarchy is an organization of different memory levels, each with distinct speed, size, and cost characteristics. The hierarchy exists because faster memories are more expensive and cannot be manufactured in large sizes.
The Hierarchy (from fastest to slowest):
| Level | Type | Speed | Size | Location |
|---|
| Level 1 | Registers | Fastest | Smallest | Inside CPU |
| Level 2 | Cache | Very Fast | Small | Near CPU |
| Level 3 | Main Memory (RAM) | Fast | Medium | Motherboard |
| Level 4 | Secondary Storage | Slowest | Largest | External devices |
Principles Behind the Hierarchy:
-
Principle of Locality: Programs access a relatively small portion of their data and instructions at any instant.
- Temporal Locality: Recently accessed data is likely to be accessed again soon
- Spatial Locality: Data near recently accessed data is likely to be accessed soon
-
Cost-Performance Ratio: Faster and smaller memories are more expensive per unit of storage. This balance ensures optimal performance at minimal cost.
1.3 Cache Memory
Cache memory is a smaller, faster memory that stores copies of data from frequently used main memory locations. It acts as a buffer between the CPU and main memory.
Cache Levels:
- L1 Cache: Closest to CPU, smallest but fastest (typically 32KB)
- L2 Cache: Larger than L1, slightly slower (typically 256KB-1MB)
- L3 Cache: Largest cache, shared among cores (typically 8MB or more)
Cache Operations:
- Cache Hit: Requested data is found in cache – fast access
- Cache Miss: Requested data is not in cache – must fetch from main memory
Example Calculation:
If a processor has a cache hit rate of 95%, a hit time of 4ns, and a miss penalty of 80ns:
AMAT=Hit time+(Miss rate×Miss penalty)
AMAT=4ns+(0.05×80ns)=4ns+4ns=8ns
1.4 Primary and Secondary Memory
Primary Memory (Main Memory):
- Includes RAM and cache memory
- Provides fast, temporary storage directly accessible by CPU
- Volatile: Loses data when power is turned off
- Example: RAM (Random Access Memory)
Secondary Memory:
- Includes hard drives, SSDs, flash memory
- Provides larger, permanent storage
- Non-volatile: Retains data without power
- Example: Hard Disk Drive (HDD), Solid State Drive (SSD)
1.5 Memory Technologies
| Technology | Type | Use | Characteristics |
|---|
| SRAM | Primary | Cache, Registers | Fast, expensive, uses transistors |
| DRAM | Primary | Main Memory | Slower than SRAM, uses capacitors, needs refresh |
| Flash | Secondary | SSDs, USB drives | Non-volatile, portable, reasonable speed |
| Magnetic Disk | Secondary | HDD | Cheapest per GB, mechanical, slowest |