NOTE
Segmentation and Paging
Operating systems organize memory through address spaces, mapping process-visible logical addresses to storage. These notes examine segments, pages, and address translation.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Address Space
1.1. Physical Address Space
To better manage memory, the operating system assigns an address to every byte of memory, forming the physical address space. The maximum size of this space is the size of memory.
1.2. Virtual Address Space
To solve the problem of insufficient memory, the operating system’s virtual-memory technology assigns an address to every byte of all storage devices, forming a virtual address space. This is also the logical address space seen by a process.
In theory, this address space can reach 2^CPU bit width - 1; of course, the actual range is MIN(memory + external-storage capacity, 2^CPU bit width - 1).
2. Memory Management
This concerns the units used to divide the process’s logical address space and the actual physical address space for easier management.
3. Paged Memory Management
Divide a process’s logical space into several equal-sized pages, and divide physical memory space into physical blocks of the same page size. The process’s pages are loaded into pages in physical memory in page units.
3.1. Page
If pages in a process’s logical space are too large, it is difficult to find a suitable memory block to allocate; if they are too small, memory fragmentation is produced. They are usually 512B-8K.
3.2. Page Table
We need to know which page in memory each page of a process has been allocated to. The page table is used to record the mapping between physical space and logical space.
As shown above, page 1 in the process’s logical space is mapped to block 1 of physical memory.
3.3. Problem
If a continuous piece of logic is distributed across multiple pages, execution efficiency will be greatly reduced.
4. Segmented Memory Management
Divide a process’s logical space into several unequal-sized segments (the segment size is determined by the size of the continuous logic), and divide physical memory space into physical blocks of the same segment size. The process’s segments are loaded into segments in physical memory in segment units.
4.1. Segment Table
As shown above, segment 1 of the process logical address space is mapped to a location in physical memory with base address 10K and segment length 30K.
4.2. Problem
This causes memory fragmentation.
4.3. Segment vs Page
| Page | Segment | |
|---|---|---|
| Unit | Physical unit | Logical unit |
| Purpose | Better management of physical memory | Better adaptation to process needs |
| Page/segment size | Page size is determined by hardware | Segment length can change dynamically |
| Page/segment table | Page-table information is one-dimensional | Segment-table information is two-dimensional |
5. Segmentation with Paging
Combines the advantages of pages and segments. Pages can effectively improve memory utilization, while segments can better satisfy user needs.
First divide the logical space into several unequal-sized segments according to segmentation management, then divide the space within each segment into several equal-sized pages according to paging management. Divide physical memory into physical blocks of the same page size, and load the process’s pages into physical memory in page units.

6. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub