1. Gyanastra
  2. Operating Systems
  3. Contiguous Memory Allocation
  4. Memory Hierarchy and CPU-Accessible Memory
Free lesson, no account needed 4 min read 8 practice questions after it

Operating Systems · Contiguous Memory Allocation

Memory Hierarchy and CPU-Accessible Memory

Overview

The CPU can directly access only three memory elements: registers, cache and main memory (RAM).
All three are expensive, so their sizes are fixed by budget, and the amount of main memory bought determines how many processes can be resident and therefore how well the CPU is utilized.

Key concepts

  • CPU-accessible memory — exactly three elements can be handed to the CPU directly: registers (inside the CPU), cache (only if the system has a cache), and main memory (RAM), the primary memory.
  • Secondary memory — the hard disk; it is not directly accessible by the CPU. Data and instructions can be placed in registers, cache or main memory, and only these three can be given to the CPU directly.
  • Cost ordering — registers are very costly compared to cache; cache is costly compared to main memory; main memory is costlier than the hard disk (secondary memory).
  • System cost consequence — because these components are costly, a system cannot be built with very large amounts of registers, very large amounts of cache, or very large amounts of main memory; doing so makes total system cost very, very high.
  • Budget decision — how much main memory to buy is a design/budget question: out of the total budget, some amount is allocated to main memory, and how much is allocated depends on how much efficiency is wanted.
  • Main memory size vs CPU efficiency — bigger main memory holds more processes; more loaded processes means more processes run without stopping; therefore CPU utilization is high.
  • Qualification — CPU utilization does not become 100% even with infinite main memory; there is only some correlation between main memory size and CPU utilization — larger main memory tends to raise utilization.
Memory diagram: Memory Hierarchy and CPU-Accessible Memory
Figure. Memory Hierarchy and CPU-Accessible Memory

How it works

  1. The CPU directly accesses only registers, cache and main memory; the hard disk is reached only indirectly.
  2. Cost per unit falls down the hierarchy: registers > cache > main memory > hard disk.
  3. Because of this cost, the amounts of registers, cache and main memory are kept limited; otherwise system cost becomes very high.
  4. The budget fixes the main memory size, chosen according to the efficiency desired.
  5. Larger main memory → more processes loaded → more processes run without stopping → higher CPU utilization (a correlation, not a guarantee of 100%).

Comparison

Memory elementDirectly accessible by CPU?Relative cost
RegistersYesHighest (very costly, costlier than cache)
Cache (if present)YesCostlier than main memory, cheaper than registers
Main memory (RAM)YesCheaper than cache, costlier than secondary memory
Secondary memory (hard disk)NoCheapest

Revision summary

  • Only registers, cache and main memory are directly accessible to the CPU; the hard disk is not.
  • Cost per unit decreases down the hierarchy: registers > cache > main memory > secondary memory (hard disk).
  • Very large registers, cache or main memory are impractical because system cost becomes very high; main memory size is fixed by budget.
  • Larger main memory → more processes resident → more processes run without stopping → higher CPU utilization.
  • More main memory does not guarantee 100% CPU utilization, not even with infinite memory; there is only a correlation.
  • Cache counts as CPU-accessible only if the system has one.

Previous-year exam insights

  • The memory hierarchy in order of decreasing speed and increasing access time is registers, cache, main memory, and secondary storage (magnetic disk/SSD); registers are the fastest and smallest, secondary storage the slowest and largest.
  • Access time increases and cost per bit decreases as one moves down the hierarchy (registers fastest and costliest per bit, secondary storage slowest and cheapest per bit), while capacity increases in the same downward direction.
  • Cache is faster but smaller and costlier per bit than main memory; it holds recently used data to bridge the speed gap between the CPU and main memory (principle of locality).
  • Main memory is volatile (contents lost on power off) whereas secondary storage is non-volatile; registers and cache are also volatile.
  • The CPU accesses main memory through the memory bus using addresses placed in the MAR, with data transferred via the MBR/MDR; secondary storage is accessed only through I/O controllers and device drivers, never directly by load/store instructions.
  • In contiguous allocation the whole process must be loaded into one contiguous block of main memory, so the degree of multiprogramming is limited by the number of free holes large enough, and external fragmentation arises as processes finish.

CPU-Accessible Memory Hierarchy

Shows which memory elements the CPU accesses directly and the decreasing cost order from registers down to the hard disk.

Pages 1–2 of 2