8 Memory Organization And Management

Microprocessor and Computer Architecture · Unit 8

Memory Organization and Management

Exam-focused notes for Memory Organization and Management (Microprocessor and Computer Architecture, BIT151): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

Memory Organization and Management in short

A computer needs memory that is fast, large and cheap, but no single device has all three. So memory is built in levels. This chapter explains the levels, the cache, virtual memory, page replacement, memory protection and the magnetic disk.

Memory Organization and Management: notes

Memory hierarchy in computer systems

The memory hierarchy arranges memories in levels. Fast, small and costly memory is near the CPU. Slow, large and cheap memory is far from it.

LevelExampleSpeedSizeCost per bit
1CPU registersFastestSmallestHighest
2Cache memoryVery fastSmall (KB to MB)High
3Main memory (RAM)FastMedium (GB)Medium
4Magnetic disk, SSDSlowLarge (TB)Low
5Magnetic tape, optical diskSlowestVery largeLowest

The hierarchy works because of locality of reference. A program tends to use the same data again soon (temporal locality) and data near the data it just used (spatial locality). So a small fast memory can hold the data in use, and the CPU sees an average speed close to the fastest level.

Main memory is made of RAM (read and write, volatile) and ROM (read only, non-volatile). Secondary memory keeps data after power is off. Cache and virtual memory are the two methods that give the hierarchy its speed and size.

Cache memory organization

Cache memory is a small, very fast memory between the CPU and main memory. It holds copies of recently used words.

  • A hit means the word is found in the cache. A miss means it must be read from main memory.
  • Hit ratio $h$ = number of hits divided by total accesses.

Average access time, with cache time $t_c$ and main memory time $t_m$:

$$t_{avg} = h,t_c + (1 - h),t_m$$

Example: $h = 0.9$, $t_c = 10$ ns, $t_m = 100$ ns. Then $t_{avg} = 9 + 10 = 19$ ns.

The mapping decides where a main memory block may be placed in the cache.

MappingHow it worksGood and bad points
DirectEach block has exactly one cache line: line = block number mod number of linesSimple and fast, but many conflicts
AssociativeA block can go in any line, found by comparing tagsFlexible, but costly hardware
Set associativeA block maps to one set, and can be in any line of that setA good balance of cost and misses

Direct mapping example. Main memory has 64K words (16-bit address), and the cache has 1K words. The address splits into a 6-bit tag and a 10-bit index. The index picks the cache line. The tag is compared to see if the stored word is the right one.

Write policies:

  • Write through: write to cache and main memory together. Memory is always up to date.
  • Write back: write only to cache and mark the line dirty. Main memory is updated when the line is replaced.

What this unit covers

  • Memory hierarchy in computer systems
  • Cache memory organization
  • Virtual memory concept
  • Page replacement algorithms
  • Page fault handling
  • Memory protection mechanisms
  • Magnetic disk storage

Memory hierarchy in computer systems

2082 · 5 marks

Explain about memory hierarchy in computer system. [5]

Memory hierarchy is an organization of different types of memory storage in a computer system, arranged in levels based on speed, cost, and capacity. The fundamental idea is that faster memory is more expensive and smaller in size, while slower memory is cheaper and larger in capacity. --- --- - ...

Open this answer on its own page →

2081 · 5 marks

Explain about memory hierarchy in computer system. [5]

Memory hierarchy is an organization of different types of memory storage in a computer system, arranged in levels based on speed, cost, and capacity. The fundamental idea is that faster memory is more expensive and smaller in size, while slower memory is cheaper and larger in capacity. --- --- - ...

Open this answer on its own page →

2078 · 5 marks

Explain about memory hierarchy in computer. [5]

Memory hierarchy is an arrangement of different types of storage in a computer system, organized in levels based on speed, cost, and capacity. Faster memories are placed at the top (closer to the CPU) and slower, larger memories at the bottom. --- --- - Located inside the CPU - Fastest memory in ...

Open this answer on its own page →

2080.1 · 5 marks

Explain memory hierarchy present in the computer system. [5]

Memory hierarchy is an arrangement of different types of storage in a computer system, organized in levels based on speed, cost, and capacity. Faster memories are placed at the top (closer to the CPU) and slower, larger memories at the bottom. --- --- - Located inside the CPU - Fastest memory in ...

Open this answer on its own page →

0 · 5 marks

Explain about memory hierarchy in computer. [5]

Memory hierarchy is an arrangement of different types of storage in a computer system, organized in levels based on speed, cost, and capacity. Faster memories are placed at the top (closer to the CPU) and slower, larger memories at the bottom. --- --- - Located inside the CPU - Fastest memory in ...

Open this answer on its own page →

Virtual memory concept

2080 · 5 marks

What is Virtual Memory? Explain in brief. [5]

Show solved answer

Virtual Memory

Definition

Virtual Memory is a memory management technique that allows a computer to execute programs that are larger than the available physical (main) memory by using a portion of the secondary storage (hard disk) as an extension of RAM.

It creates an illusion for the user/process that a very large memory space is available, even when the actual physical memory is limited.


Key Concepts

1. Virtual Address Space

  • Each process is given its own virtual address space, which is independent of physical memory locations.
  • The CPU generates virtual (logical) addresses, which are translated to physical addresses by the Memory Management Unit (MMU).

2. Paging and Demand Paging

  • Virtual memory is commonly implemented using paging.
  • In demand paging, pages are loaded into physical memory only when needed (on demand), not all at once.
  • If a required page is not in physical memory, a page fault occurs, and the OS loads the page from disk.

3. Page Fault Handling

When a page fault occurs:

  1. The OS detects the missing page.
  2. It finds the page on the disk (swap space).
  3. It loads the page into a free frame in physical memory.
  4. Updates the page table.
  5. Resumes the process.

4. Swapping

  • When physical memory is full, the OS swaps out (removes) a page from memory to disk using a page replacement algorithm (e.g., FIFO, LRU, Optimal).

Advantages of Virtual Memory

AdvantageDescription
Larger address spacePrograms can be larger than physical RAM
MultiprogrammingMore processes can run simultaneously
Memory isolationEach process has its own address space
Efficient memory useOnly needed pages are loaded

Disadvantages

  • Slower performance due to disk access (page faults are costly).
  • Thrashing can occur if too many page faults happen frequently, causing the system to spend more time swapping than executing.

Summary

Virtual memory separates the logical memory seen by the user from the physical memory of the system, enabling efficient, safe, and flexible memory management in modern operating systems.

Open this answer on its own page →