Skip to content

Memory Management: Paging, Segmentation and Virtual Memory

1.2.1 Systems software · Paper 1 · 4 flashcards · 1 question

Definition
Memory management is crucial for a computer system to run efficiently. It involves managing the computer's physical memory and optimising its usage across various applications.

Paging

Definition
Paging divides memory into fixed-sized blocks called pages. Programs are split into pages, which can be swapped between main memory and secondary storage as needed.
Key Point
Paging Characteristics:
• Fixed-size blocks (typically 4KB)
• Eliminates external fragmentation
• Allows non-contiguous memory allocation
• Uses page tables to track memory locations

Segmentation

Definition
Segmentation divides memory into variable-sized segments, reflecting the logical divisions within a program, such as functions or data structures.
Key Point
Segmentation Characteristics:
• Variable-sized segments based on program logic
• Each segment has a name and length
• Can lead to external fragmentation
• More intuitive for programmers (reflects code structure)

Virtual Memory

Definition
Virtual memory uses a portion of the hard drive to extend RAM, allowing the system to handle more applications than the physical memory could otherwise support.
Key Point
Virtual Memory Benefits:
• Programs can be larger than physical RAM
• Multiple programs can run simultaneously
• Isolation between processes (security)
• Efficient memory utilisation

Virtual Memory Downsides:
• Slower than physical RAM (disk access)
• Disk thrashing can occur if overused

Disk Thrashing

Definition
Disk thrashing is a situation where excessive paging or swapping between main memory and disk storage leads to a significant slowdown in system performance, often causing the system to freeze.
Exam Tip
Disk thrashing occurs when the system spends more time moving pages between RAM and disk than executing instructions. Solution: Add more RAM or reduce the number of running applications.

Paging and Segmentation Compared

FeaturePagingSegmentation
Size of the blocksFixed size (pages)Variable size (segments)
How memory is dividedPhysically, taking no account of how the program is structuredLogically, each segment matching a part of the program such as a subroutine or data structure
FragmentationInternal: the last page of a program may not be fullExternal: gaps are left between segments that may be too small to use

Both methods let a program be stored in parts that are not next to each other in memory, and both let the parts that are not in use be moved to virtual memory.

Key Point
What memory management does:
• Allocates RAM to each program and frees it when it is no longer needed
• Stops a program from accessing memory allocated to another program, which keeps data secure
• Moves pages that are not currently needed out to virtual memory when RAM is nearly full, and back again when they are required