Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1: Memory Hierarchy

Lesson 9 of 34 in the free Fundamentals of IT & Computers notes on Siksha Sarovar, written by Rohit Jangra.

Unit I — Memory Hierarchy

A computer uses multiple types of memory organised in a hierarchy. As you move up the hierarchy, memory becomes faster and more expensive, but smaller in capacity. As you move down, it becomes slower, cheaper, and larger.

---

The Memory Hierarchy (Top to Bottom)

LevelTypeSpeedCostCapacity
1CPU RegistersFastestHighestBytes
2Cache Memory (L1, L2, L3)Very fastVery highKB–MB
3Primary Memory (RAM)FastModerateGB
4Secondary Memory (HDD/SSD)SlowLowTB
5Tertiary/Offline (Tape, Cloud)SlowestCheapestPB

---

Why a Hierarchy?

An ideal memory would be infinitely large, infinitely fast, and free. In reality, no single technology satisfies all three. The hierarchy exploits the principle of locality:

  • Temporal Locality: Recently accessed data is likely to be accessed again soon (keep it in fast cache).
  • Spatial Locality: Data near recently accessed locations is likely to be accessed soon (prefetch into cache).

---

Levels Explained

Registers

  • Built into the CPU chip itself.
  • Accessed in a single clock cycle (sub-nanosecond).
  • Capacity: typically 32 or 64 registers of 32/64 bits each.

Cache Memory

  • Acts as a buffer between the fast CPU and slower RAM.
  • L1 Cache: Smallest and fastest; inside the CPU core.
  • L2 Cache: Slightly larger; inside or near the CPU.
  • L3 Cache: Shared among CPU cores; larger but slower than L1/L2.

Primary Memory (RAM)

  • Main working memory; holds running programs and data.
  • Volatile — contents lost when power is off.
  • Access time: ~50–100 nanoseconds.

Secondary Memory

  • Permanent storage (hard disks, SSDs, optical discs).
  • Non-volatile — data persists without power.
  • Access time: milliseconds (HDD) to microseconds (SSD).

Tertiary / Offline Storage

  • Magnetic tapes, cloud storage.
  • Used for archival and backup.
  • Very slow access but virtually unlimited capacity.

---

Memory Access Time Comparison

TypeTypical Access Time
Register< 1 ns
L1 Cache1–4 ns
L2 Cache4–12 ns
RAM50–100 ns
SSD50–150 µs
HDD5–10 ms
Key Takeaway: The memory hierarchy is a trade-off between speed, cost, and capacity. Registers and cache are fast but small; secondary storage is large but slow. The CPU always tries to find data in the fastest (highest) level first before going lower.