CSE 513
CSE 513 · WEEK 05 · READING

Memory management and address translation

How does a process get its own view of memory?

Select figures for full-size views. Predict each mapping and cache transition before opening the worked answer.

1. A process has an address space

A program runs by fetching instructions and reading or writing data. Every such operation refers to an address. If those addresses were unrestricted physical locations, a mistake in one program could overwrite another program or the operating system itself. Memory management must provide usable storage while controlling which locations each execution context can reach. It must also allow deliberate sharing, because shared code and communication can be valuable.

The central abstraction is the address space: the collection of addresses a process can use, together with the mappings and access rules that give those addresses meaning. A virtual address is interpreted in a process context. Two processes can use the numerical address 0x1234 and access different physical locations. Conversely, two different virtual addresses can map to the same physical location when sharing is intended. Neither equality nor inequality of the printed numbers settles whether the underlying storage is shared.

The operating system establishes and changes mappings. Hardware uses them during execution and rejects disallowed accesses. Keeping these roles distinct explains why the OS does not need to execute a system call for every ordinary load or store. It is involved in setting up the policy and in exceptional events; the normal access path can proceed through hardware translation and permission checks.

A base and limit illustrate a simple protected region.
A base and limit illustrate a simple protected region. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 5. Select for full-size view.
Predict: can a process isolate itself merely by promising to stay inside its allocation?

No. A buggy or hostile instruction could ignore that promise. The boundary must be enforced by a mechanism the process cannot freely reconfigure. In the base/limit model, loading the protection registers is privileged. In paging, the page tables and associated control state must likewise be protected.

2. Binding names to addresses

Source programs refer to symbolic objects such as a variable or function. Compilation produces object code whose references may still need adjustment. Linking combines modules and resolves references; loading places the resulting program into a usable address space. These transformations explain why a name in source code, an offset in an object module and an address used by a running process are not interchangeable descriptions.

Compile-time binding assumes a known placement and generates addresses accordingly. Load-time binding leaves relocation to the loader. Execution-time binding permits an address generated during execution to be translated to its current physical location. These are conceptual alternatives, not a claim that a contemporary executable performs only one kind of address resolution throughout its life.

A program passes through compilation, linking and loading; follow where references are resolved.
A program passes through compilation, linking and loading; follow where references are resolved. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 9. Select for full-size view.

Dynamic loading delays bringing a routine into use until it is needed. Dynamic linking delays resolving a connection to separately supplied library code. A program can use either idea without making them synonymous. Shared library code can be mapped by several processes, but writable state and permissions still require careful treatment. Demand paging, introduced next week, adds another distinction: a mapped virtual range need not have all its pages resident in RAM at once.

Explain: does successful linking reveal the physical address of every variable?

No. Linking resolves program references under an executable and address-space model. Execution-time mapping can place the relevant virtual pages in different physical frames. A linked address and a physical RAM address belong to different stages of the explanation.

The MMU separates the logical address generated by the CPU from the physical address used by memory.
The MMU separates the logical address generated by the CPU from the physical address used by memory. Silberschatz, Galvin and Gagne, OSC 10e, Chapter 9, slide 11. Select for full-size view.

3. Relocation and bounds must work together

Start with a deliberately small model: a process generates a nonnegative logical offset, and a relocation register contains the physical base of its allocated region. Translation adds the base to the offset. With base 14000, logical offset 346 becomes physical address 14346. If the region moves and the base changes, the process can keep using the same offsets.

Relocation adds the current base to the logical offset.
Relocation adds the current base to the logical offset. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 13. Select for full-size view.

Translation alone is insufficient. An offset outside the allocated length would still produce a number, but that number could refer to someone else’s memory. With limit 1000, the legal offsets are 0 through 999 inclusive. The check is offset < limit, not offset ≤ limit. Only after the check succeeds should the mechanism add the base.

The limit comparison precedes relocation in this offset-based model.
The limit comparison precedes relocation in this offset-based model. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 18. Select for full-size view.
Base 14000 and length 1000
Logical offsetDecisionPhysical address
0Legal14000
346Legal14346
999Legal14999
1000RejectedNo permitted result

Another textbook diagram checks an already physical address against the interval base ≤ address < base + limit. That is a different placement of the check. Read the diagram’s input label before applying a formula. Mixing the physical-interval model with the offset model is a common source of off-by-one and double-addition errors.

Predict: should offset 1000 become physical 15000 because that byte exists?

No. Existence in physical memory does not establish permission for this process. The offset equals the region length and is outside the permitted interval. The correct result is rejection, not a physical address.

This alternative protection diagram checks a physical address against the permitted interval. It does not add the base a second time.
This alternative protection diagram checks a physical address against the permitted interval. It does not add the base a second time. Silberschatz, Galvin and Gagne, OSC 10e, Chapter 9, slide 6. Select for full-size view.

4. Contiguous allocation and placement policies

In contiguous allocation, a process is assigned one continuous physical interval. Free intervals are holes. A new allocation can split a hole into an allocated region and a smaller remaining hole. When an allocation is freed, adjacent holes can be coalesced. These operations change the future choices, so a placement policy must be evaluated on a sequence rather than a single request.

Process arrivals and departures change the pattern of allocated regions and holes.
Process arrivals and departures change the pattern of allocated regions and holes. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 19. Select for full-size view.

First fit searches in address order and selects the first hole large enough. Best fit selects the smallest sufficient hole. Worst fit selects the largest. For a reproducible comparison, begin each policy with the same state and state how ties, splitting and coalescing work. In the following exercise, holes are listed in address order; the chosen hole is split; no process exits during the sequence.

Initial holes: 100, 500, 200, 300, 600 KiB; requests: 212, 417, 112, 426 KiB
RequestFirst fitBest fitWorst fit
212500 → 288300 → 88600 → 388
417600 → 183500 → 83500 → 83
112288 → 176200 → 88388 → 276
426Cannot fit600 → 174Cannot fit

After the first three first-fit allocations, the holes are 100, 176, 200, 300 and 183 KiB. Their sum is 959 KiB, yet the next request of 426 KiB cannot fit because the largest single hole is only 300 KiB. Best fit succeeds for this particular sequence. That observation is an example outcome, not a proof that best fit dominates every possible workload.

Try before reading: what are the final best-fit holes after all four requests?

In the original address order they are 100, 83, 88, 88 and 174 KiB. Their total is 533 KiB. The initial 1700 KiB minus requests totaling 1167 KiB also gives 533 KiB. This independent conservation check helps catch arithmetic mistakes.

5. Two kinds of fragmentation

External fragmentation means that free space exists between allocations but cannot satisfy a requirement for one sufficiently large contiguous region. Internal fragmentation means that an allocated unit contains unused bytes. The external case concerns how free regions are arranged; the internal case concerns unused space inside a reserved unit. Always name the unit and allocation model when using these terms.

Compaction can gather scattered free space by moving allocated regions. It requires safe relocation of references and incurs copying cost. An outstanding I/O operation might still refer to the old location; the system must coordinate that operation or use an appropriate buffering arrangement. “Move the process” is therefore a policy idea with implementation obligations, not a cost-free diagram operation.

Paging changes the allocation unit to fixed-sized frames. A process can use separated frames, which removes the requirement for one large contiguous process region. Its final page can still be partially unused. Other system allocations may still require contiguous physical regions, so it is too broad to conclude that paging eliminates every fragmentation issue in an entire operating system.

Calculate: a 72766-byte allocation uses 2048-byte pages. How much internal fragmentation is there?

35 complete pages contain 71680 bytes, leaving 1086 bytes for a 36th page. The allocation reserves 73728 bytes. The unused tail is 2048 − 1086 = 962 bytes. A half-page average is meaningful only under assumptions about the distribution of final-page occupancy.

Reflect: why not always use very small pages?

Smaller pages can reduce the unused tail, but they require more page-table entries for a given address range and can reduce the bytes covered by a fixed number of TLB entries. Allocation granularity, translation overhead and the workload must be considered together.

Schematic, not to scale. Compaction relocates allocations; it does not remove unused space inside an allocation.
Schematic, not to scale. Compaction relocates allocations; it does not remove unused space inside an allocation. CSE513 teaching illustration · AI-generated, reviewed for this worked model. Select for full-size view.

6. Segmentation as a logical organization

A programmer may think of memory as several logical regions: code, a stack, tables and arrays. Segmentation represents that view using variable-sized regions. An address is a pair (segment number, offset). The segment number chooses a table entry; that entry supplies the region’s base and length, along with permissions. The offset must be within the segment before the base is added.

Segment selection, limit checking and base addition form one translation path.
Segment selection, limit checking and base addition form one translation path. Historical BIL601 memory-management lecture, Mehmet Göktürk; adapted Operating System Concepts segmentation figure. Cropped from the original slide. Select for full-size view.

For segment 0 with base 1400 and length 1000, offset 430 reaches physical address 1830. Segment 1 with base 6300 and length 400 admits offset 399, producing 6699, but rejects offset 400. The existence of physical byte 6700 is irrelevant to whether that segment permits the reference.

Variable-sized program regions are placed in physical memory through the segment table.
Variable-sized program regions are placed in physical memory through the segment table. Historical BIL601 memory-management lecture, Mehmet Göktürk; adapted Operating System Concepts segmentation figure. Cropped from the original slide. Select for full-size view.

Segmentation makes region boundaries explicit, but allocating variable-sized regions can produce external fragmentation. Paging uses uniform units that do not need to correspond to source-language objects. Some historical architectures combine the mechanisms: segmentation produces a linear address, which paging then translates. Here segmentation supplies context and comparison; it is not a claim that current Ubuntu processes use the historical BIL601 diagram unchanged.

Compare: is a C array necessarily one hardware segment or one page?

Neither follows from the source-language object. It may span pages, share a page with other objects or be part of a larger mapping. Source-level regions are a useful way to motivate segmentation, but they do not uniquely determine the implementation’s memory layout.

7. Pages, frames and offset preservation

A page is a fixed-sized unit of virtual memory; a frame is a same-sized unit of physical memory. A page table records the mapping from a virtual page number to a frame. The process can see consecutive virtual addresses even when the frames backing consecutive pages are separated in RAM. The offset identifies a byte within the page and is preserved during translation.

The page table connects ordered virtual pages to potentially scattered physical frames.
The page table connects ordered virtual pages to potentially scattered physical frames. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 26. Select for full-size view.

For byte address A and page size P, compute p = floor(A/P) and d = A mod P. After finding a valid, permitted mapping to frame f, the physical address is f × P + d. Do not add the original whole virtual address to the frame base: that would count the virtual-page contribution a second time.

The page number selects a mapping; the offset bypasses the page-table lookup.
The page number selects a mapping; the offset bypasses the page-table lookup. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 25. Select for full-size view.

If P is 2ⁿ bytes, the low n address bits are the offset. With 4 KiB pages, n = 12. A 32-bit virtual address then has 20 virtual-page bits and 12 offset bits. The physical frame-number width is determined by the physical address space, not automatically by the virtual width. Using KiB and MiB explicitly avoids confusing powers of two with decimal units.

Derive: what are the page number and offset of byte address 8191 with 4096-byte pages?

8191 = 1 × 4096 + 4095, so the page number is 1 and the offset is 4095. The next byte address, 8192, is page 2 at offset 0. The transition can select an entirely different physical frame.

8. Work a translation all the way to a byte

A tiny 4-byte-page example makes the mapping visible at individual-byte scale.
A tiny 4-byte-page example makes the mapping visible at individual-byte scale. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 27. Select for full-size view.

In the original miniature example, virtual pages 0, 1, 2 and 3 map to frames 5, 6, 1 and 2. Virtual address 6 has page number 1 and offset 2, so it reaches physical address 6 × 4 + 2 = 26. Distinguish the virtual address 6 from frame number 6: they are numerically equal here but have different meanings.

Now use a larger teaching table. Page size is 4096 bytes. Every mapped page below is resident; the table deliberately separates mapping existence from permission. We will use the same state in the supplied simulator so predictions can be checked exactly.

Four-page teaching address space
Virtual pagePhysical frameState
03Mapped, read/write
19Mapped, read-only
2—Unmapped
31Mapped, read/write

A read at 0x1234 starts with decimal address 4660. Dividing by 4096 gives page 1 and remainder 564, or 0x234. Page 1 selects frame 9, whose physical base is 36864, or 0x9000. The result is 37428, or 0x9234. The low twelve bits are unchanged. A write at the same address is rejected, because that mapping is read-only.

Boundary and permission checks
AccessPage / offsetResult
Read 0x0FFF0 / 4095Physical 0x3FFF
Read 0x10001 / 0Physical 0x9000
Read 0x12341 / 564Physical 0x9234
Write 0x12341 / 564Protection rejection
Read 0x20002 / 0Unmapped
Predict: why are physical 0x3FFF and 0x9000 not adjacent even though the virtual addresses are?

The virtual access crossed a page boundary. Page 0 maps to frame 3, while page 1 maps to frame 9. Within each page, offsets remain consecutive, but the table makes no promise that consecutive virtual pages use consecutive frames.

Explain: must every page-table rejection lead to loading a page from disk?

No. An illegal address or a prohibited write does not become legal by loading data. A legal virtual page that is nonresident is a different case, developed in Week 6. First determine the meaning of the state and the intended access.

Page 1 maps to frame 9. With 4 KiB pages, offset 0x234 gives physical address 0x9234.
Page 1 maps to frame 9. With 4 KiB pages, offset 0x234 gives physical address 0x9234. CSE513 teaching illustration · AI-generated, reviewed for this worked model. Select for full-size view.

9. Page tables and the address of an entry

A page table is metadata, not a second copy of the program. It records which frame, if any, corresponds to a virtual page and which operations are permitted. In a simple one-level model, the page-table base register identifies a physical table base. If entries have fixed size, the page number indexes an entry by ordinary arithmetic.

Assume PTBR = 0x8000 and an entry size of eight bytes. Page 1’s entry is stored at 0x8008. Reading that entry may reveal frame 9, but 0x8008 is not the address of the program’s data. For offset 0x234, the data address is 0x9234. Students should explicitly label the entry address, the entry contents and the final data address; collapsing them into one number hides the mechanism.

Free-frame bookkeeping and a process page table describe different sides of allocation.
Free-frame bookkeeping and a process page table describe different sides of allocation. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 29. Select for full-size view.

Without a translation cache, a one-level translation requires reading the PTE and then accessing the requested instruction or data. This explains why a straightforward table in RAM can add substantial overhead. The normal solution is to cache translations, rather than to discard the isolation provided by translation.

Calculate: with PTBR 0x8000 and eight-byte entries, where is the entry for page 3?

At 0x8000 + 3 × 8 = 0x8018. This is the location of the PTE. The frame number stored there is needed before computing the final data address.

10. The TLB remembers translations

A translation lookaside buffer, or TLB, caches translations and associated access information. It stores the answer to “which frame and permissions apply to this virtual page in this address space?” A data cache instead stores instruction or data bytes. A processor may use both mechanisms during one access, but a hit in one does not logically imply a hit in the other.

A TLB hit supplies a translation; a miss requires consulting the page-table mechanism.
A TLB hit supplies a translation; a miss requires consulting the page-table mechanism. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 33. Select for full-size view.

Use a toy TLB with two fully associative entries, LRU replacement and initially empty contents. All pages in the following trace are mapped and resident. “Old → new” lists the least recently used entry first. A hit changes recency; a miss may evict a cached translation without evicting the page’s data from RAM.

Reference pages 0, 1, 0, 2, 1
PageOutcomeContents after access, old → new
0Miss0
1Miss0, 1
0Hit1, 0
2Miss; evict 10, 2
1Miss; evict 02, 1

This trace has one hit and four misses. It has zero demand-paging faults under the stated resident-mapping assumption. The label “page 2” in this independent TLB exercise does not inherit the unmapped state from the earlier four-page translation exercise: each example states its own initial conditions. The supplied simulator uses the earlier table and therefore uses page 3 in its corresponding replacement trace.

Explain: does a TLB miss imply a disk access?

No. A valid resident mapping can be recovered from the page table. The translation was absent from a cache; the data page need not be absent from RAM. Whether the miss is handled by hardware or software is architecture dependent.

Address-space identifiers can distinguish cached translations belonging to different processes. Without an appropriate context distinction, old translations must be invalidated when changing address spaces. Changes to permissions or mappings also require cached translations to remain consistent. The principle is that a cached decision must not outlive the state on which it depends.

11. Calculate access time under explicit assumptions

A latency calculation is meaningful only after the access model is stated. Assume a serial TLB lookup taking t = 1 ns, each memory access taking m = 100 ns, a one-level table, resident pages and no other caches. A hit costs t + m = 101 ns. A miss costs t + 2m = 201 ns because it reads one PTE before the data. With hit ratio h, the expected cost is h(t + m) + (1 − h)(t + 2m).

One-level serial lookup model
Hit ratioExpected access timeExtra over a 100 ns untranslated baseline
80%121 ns21%
95%106 ns6%
99%102 ns2%
100%101 ns1%

For h = 0.95, the calculation is 0.95 × 101 + 0.05 × 201 = 106 ns. If a source ignores TLB lookup time, its formula differs because its assumptions differ. Do not combine a hit cost from one model with a miss cost from another. Also keep the comparison baseline visible: slowdown relative to 100 ns is not the same percentage as slowdown relative to 101 ns.

These values illustrate the effect of translation caching. They are not benchmark predictions. Real processors have cache hierarchies, page-walk caches, parallel activity and architecture-specific paths. An experiment that times a loop does not isolate TLB overhead simply because the loop touches memory.

Calculate: what is the expected cost for two table levels and h = 0.95, keeping the same serial model?

A miss now costs 1 + 3 × 100 = 301 ns: two PTE reads and one data access. A hit still costs 101 ns. The weighted result is 0.95 × 101 + 0.05 × 301 = 111 ns. No page-in or disk cost is included.

12. Protection and sharing coexist

Translation answers where an access would go; protection answers whether the requested operation is permitted. A frame number alone does not authorize a write. Cached translations must retain or enforce the relevant permission information, so a TLB hit is not a way around protection. The supplied simulator makes this visible by reading a read-only page and then attempting a write that hits the cached translation.

The source valid/invalid example concerns membership in the legal logical address space.
The source valid/invalid example concerns membership in the legal logical address space. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 36. Select for full-size view.

The word “valid” is used in different teaching models. In this source figure it marks whether a page belongs to the logical address space. A separate residency model asks whether a legal page currently has a usable physical frame. Real architectures encode state in their own way. Ask what a bit means before deciding whether the right response is rejection, a table walk or a page-fault service operation.

Read-only code frames can be shared while processes keep private data.
Read-only code frames can be shared while processes keep private data. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 38. Select for full-size view.

Suppose process A maps virtual page 1 to frame 9 read-only, while process B maps virtual page 7 to frame 9 read/write. With 4096-byte pages, A’s 0x1234 and B’s 0x7234 both reach physical 0x9234. A cannot write through its mapping, but B can write through its own. Read-only for one mapping does not make the physical frame immutable to every participant.

Connect to Week 3: does shared writable memory make a counter update safe?

No. Mapping provides access to the same storage; it does not make a read-modify-write sequence atomic or establish an appropriate synchronization protocol. Permission and race freedom are different requirements.

Both mappings reach the same byte. The access check uses the permissions of the mapping used by the process.
Both mappings reach the same byte. The access check uses the permissions of the mapping used by the process. CSE513 teaching illustration · AI-generated, reviewed for this worked model. Select for full-size view.

13. Sparse address spaces and multilevel tables

A 32-bit byte address space with 4096-byte pages has 2²⁰ virtual pages. At four bytes per entry, a full linear table occupies 2²² bytes, or 4 MiB, per address space. Much of that table may describe unused ranges. Hierarchical tables make it possible to omit lower-level structures for large unmapped regions.

An outer table connects only the regions needing lower-level tables.
An outer table connects only the regions needing lower-level tables. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 40. Select for full-size view.

For a two-level 32-bit model with 4 KiB table pages and four-byte entries, a table page contains 1024 entries. Split the virtual address into a 10-bit outer index, a 10-bit inner index and a 12-bit offset. The outer entry locates an inner table; the inner entry locates the data frame. This split follows from the selected sizes, not from the phrase “two-level” alone.

The 10 / 10 / 12 division follows from the example’s entry and page sizes.
The 10 / 10 / 12 division follows from the example’s entry and page sizes. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 41. Select for full-size view.
A two-level walk finds a leaf mapping before combining it with the offset.
A two-level walk finds a leaf mapping before combining it with the offset. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 42. Select for full-size view.
Walk virtual address 0x00403004; four-byte entries
StepCalculationMeaning
SplitOuter 1; inner 3; offset 4Virtual fields
Root at 0x10000x1000 + 1 × 4 = 0x1004Entry points to inner base 0x5000
Inner at 0x50000x5000 + 3 × 4 = 0x500CEntry names frame 0xA
Physical data0xA × 4096 + 4 = 0xA004Requested byte

If only three distinct outer-index regions need leaf tables, this model allocates one root page and three leaf pages: 16 KiB of table storage. A fully populated hierarchy needs 1025 table pages, slightly more than a linear table’s 1024 pages. The benefit depends on sparsity. Count the tables actually allocated; do not assume a hierarchy is always smaller.

Predict: does mapping one extra page always allocate a new leaf table?

No. If the page belongs to an outer region whose leaf table already exists, it can use another entry in that table. A new leaf table is needed only when the relevant region lacks one under this model.

14. Large spaces, alternative tables and page sizes

Increasing the virtual address width makes a flat table grow rapidly. A hypothetical full 64-bit byte space with 4 KiB pages has 2⁵² possible entries. Real implementations can support fewer virtual address bits than the register width, and virtual and physical widths can differ. Treat a large-space arithmetic example as a model unless a particular architecture and mode are specified.

A large virtual-address model exposes the growth of the outer table.
A large virtual-address model exposes the growth of the outer table. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 43. Select for full-size view.
Additional levels separate large unused ranges without allocating every possible leaf.
Additional levels separate large unused ranges without allocating every possible leaf. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 44. Select for full-size view.

Hashed tables organize candidate mappings by a hash of the virtual page identity. Collisions require comparing keys. Inverted tables organize information around physical frames, reducing dependence on the size of the virtual space but complicating lookup and shared mappings. These alternatives demonstrate representation trade-offs; they are not interchangeable descriptions of every operating system.

A hash bucket can contain several candidates, so the key must be checked.
A hash bucket can contain several candidates, so the key must be checked. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 46. Select for full-size view.
An inverted organization associates entries with physical frames.
An inverted organization associates entries with physical frames. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 48. Select for full-size view.

Page size also affects translation. A toy TLB with 64 entries covers at most 256 KiB with 4 KiB pages, or 128 MiB with 2 MiB pages, if each entry maps one page of that size. This nominal reach is not a promise that every access will hit. Larger pages can reduce table entries and increase reach, while smaller pages can reduce unused space and provide finer granularity.

Reflect: why can shared memory complicate a one-entry-per-frame inverted table?

One physical frame may be reachable through multiple virtual mappings, perhaps in different processes. A representation that stores only one owner/address pair needs additional machinery to describe or discover all those aliases.

15. Relate the model to Linux carefully

Linux kernel documentation describes a software page-table hierarchy named PGD, P4D, PUD, PMD and PTE. Unused levels can be folded to match an architecture. The five names therefore do not establish that every load on every Linux system performs five hardware table accesses. The architecture, enabled mode and kind of leaf mapping matter. See the kernel page-table documentation for the implementation vocabulary.

The historical Intel examples in the source explain segmentation followed by paging. They are useful for distinguishing logical, linear and physical addresses. Solaris and older ARM examples likewise illustrate specific designs. Their fixed widths and page sizes should not be treated as current universal limits. In particular, keep Intel 64 / x86-64 terminology distinct from IA-64.

On Linux, /proc/PID/maps describes mapped virtual regions and access permissions. Its address interval has an exclusive upper endpoint. Permissions include read, write and execute, with private/shared mapping information. This file does not provide a direct physical-frame mapping or prove that every page in a range is resident. Consult proc_pid_maps(5) when interpreting fields.

Interpret: what does a range 00400000–00402000 describe, in hexadecimal, with 4096-byte pages?

Its virtual length is 0x2000 = 8192 bytes, spanning two base pages under the stated size. The last included byte is 0x00401FFF. The range alone does not identify physical frames or prove residency.

Whole-process swapping is another historical model: transfer an image out and later restore it, with relocation determining whether it must return to the same place. Page-level movement gives finer control. Week 6 will examine demand paging, replacement, copy-on-write, locality and thrashing; the present chapter supplies the translation and permission framework they require.

Whole-process swapping moves an image between memory and backing store.
Whole-process swapping moves an image between memory and backing store. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 53. Select for full-size view.
Page-level backing permits a different residency decision for each virtual page.
Page-level backing permits a different residency decision for each virtual page. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 57. Select for full-size view.

16. Optional practice: predict, observe and explain

The two small C programs below support optional study, not a new graded assignment. AI assistance is permitted. Use it to propose predictions or locate mistakes, then verify the explanation against the model, source code and output. Preserve the exact source and commands you used. A plausible explanation is not a substitute for tracing the computation.

Download translate.c. This deterministic simulator uses the four-page table from Section 8, 4096-byte pages and a two-entry fully associative LRU TLB. All mapped pages are resident. Successful accesses update recency; rejected accesses leave the cache unchanged. It does not read the host’s physical page tables or simulate disk-backed faults.

cc -std=c11 -Wall -Wextra -Werror -O2 translate.c -o translate
./translate

Before running, write down page number, offset, TLB contents and result for each source-code call. The successful reference pages are 0, 1, 0, 3, 1. Then a write to page 1 tests permission enforcement on a TLB hit. Finally pages 2 and 4 test rejection of an unmapped page and an address beyond the table. These cases check different boundaries.

Expected checkpoints for translate.c

Read 0x0FFF gives 0x3FFF (miss); 0x1000 gives 0x9000 (miss); 0x0001 gives 0x3001 (hit); 0x3000 gives 0x1000 (miss); 0x1234 gives 0x9234 (miss). Writing 0x1234 hits in the TLB but reports PROTECTION. Reads at 0x2000 and 0x4000 report UNMAPPED. Explain each state transition rather than only checking the final line.

Download address-view.c. This program prints its PID, base page size and addresses of a static object, an automatic object and a dynamically allocated object. On Linux it also reads its own /proc/self/maps, so the pointer values and map belong to the same process. This avoids accidentally inspecting a separate command’s address space.

cc -std=c11 -Wall -Wextra -Werror -O2 address-view.c -o address-view
./address-view
./address-view
uname -a
cc --version

Find the interval containing each printed pointer and explain its permissions. Compare runs without assuming that an object must appear at a fixed address or that every allocation must belong to a region labeled [heap]. Use sysconf(_SC_PAGESIZE) to discover the base page size; do not substitute the lecture’s 4096-byte model for the machine’s reported value.

The programs were compiled and executed on the preparation host, macOS, with strict warnings. The simulator’s full output was checked. The Linux-specific maps branch has not been executed on Ubuntu during preparation; students should record their Ubuntu observations and any environment restrictions. Native pointers and maps reveal virtual layout, not a physical frame number or a TLB hit rate.

Study extension: change page 1 from frame 9 to frame 5 and rerun the simulator from empty state. What should change?

A permitted read at 0x1234 now reaches 0x5234. The page number and offset are unchanged; the physical frame changes. The write is still prohibited if the read-only permission is unchanged. Starting with an empty cache avoids introducing an unmodeled stale-translation problem.

17. Textbook figures for comparison

These original illustrations extend the chapter’s worked explanations. First identify the input address, the fields used to index a table and the unchanged offset. For the Intel and ARM examples, keep the named historical model separate from the configuration of the machine you inspect.

Page-number and offset fields

For a 2^m-byte address space and 2^n-byte pages, p has m−n bits and d has n bits.
For a 2^m-byte address space and 2^n-byte pages, p has m−n bits and d has n bits. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 24. Select for full-size view.

Associative translation lookup

Search page numbers in parallel. A matching entry supplies a frame number; the offset passes through unchanged.
Search page numbers in parallel. A matching entry supplies a frame number; the offset passes through unchanged. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 32. Select for full-size view.

A two-level split for a 64-bit model

The 42 / 10 / 12 split leaves an impractically large outer table. Compare it with the three-level example in the main lecture.
The 42 / 10 / 12 split leaves an impractically large outer table. Compare it with the three-level example in the main lecture. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 44. Select for full-size view.

IA-32 segment selector

Historical protected-mode model: the selector has a 13-bit index, a table-selection bit and two privilege bits.
Historical protected-mode model: the selector has a 13-bit index, a table-selection bit and two privilege bits. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 60. Select for full-size view.

IA-32 page-address fields

Historical two-level model with 4 KiB pages: two 10-bit indices and a 12-bit byte offset.
Historical two-level model with 4 KiB pages: two 10-bit indices and a 12-bit byte offset. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 61. Select for full-size view.

IA-32 translation stages

Segmentation produces a linear address. Paging then translates that linear address to a physical address.
Segmentation produces a linear address. Paging then translates that linear address to a physical address. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 61. Select for full-size view.

IA-32 segmentation

The selector identifies a descriptor. Its base and the offset form the linear address, subject to access and bounds checks.
The selector identifies a descriptor. Its base and the offset form the linear address, subject to access and bounds checks. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 62. Select for full-size view.

IA-32 paging alternatives

Historical diagram: a directory entry can lead to a page table or map a larger page directly. Follow each path separately.
Historical diagram: a directory entry can lead to a page table or map a larger page directly. Follow each path separately. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 63. Select for full-size view.

IA-32 physical address extension

PAE adds a directory-pointer level and wider entries. Offset: bits 11–0. A process still uses a 32-bit linear address.
PAE adds a directory-pointer level and wider entries. Offset: bits 11–0. A process still uses a 32-bit linear address. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 64. Select for full-size view.

A four-level x86-64 model

Historical 48-bit virtual-address example. The upper bits must satisfy canonical-address rules; this is not a universal current limit.
Historical 48-bit virtual-address example. The upper bits must satisfy canonical-address rules; this is not a universal current limit. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 65. Select for full-size view.

Historical ARM page and section mappings

Compare a direct section mapping with a two-level page mapping. The page sizes shown belong to this historical ARM model.
Compare a direct section mapping with a two-level page mapping. The page sizes shown belong to this historical ARM model. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9, slide 66. Select for full-size view.
Compare: does PAE turn a 32-bit process into a process with a 36-bit linear address?

No. The extension increases the physical-address capacity of the illustrated system. The process still uses a 32-bit linear address; its mappings select frames from the larger physical space. Address width must always be identified as virtual, linear or physical before comparing numbers.

18. Review, references and preparation for Week 6

Practice explaining one access from start to finish: identify the address space, divide the address, resolve the mapping, check the requested operation and form the physical result. Then add a TLB and distinguish a cached answer from the authoritative mapping. Finally replace the linear table with a hierarchy and count the structures and accesses under stated assumptions.

Integrated problem: A page 1 maps read-only to frame 9; B page 7 maps read/write to frame 9. With 4096-byte pages, compare A:0x1234 and B:0x7234.

Both name physical 0x9234. A may read but not write through that mapping; B may write. A TLB miss alone does not imply disk access if the mapping is resident. If several threads or processes perform updates through writable mappings, synchronization is still required. Read-only for A does not make the shared byte immutable to B.

Self-check: which four confusions should you be able to correct?

A PTE address is not the data address; a TLB miss is not automatically a page-in; a virtual pointer does not reveal a physical frame; and a hierarchy does not save memory for every possible population pattern. Give a numerical or structural counterexample for each.

Keep a study sheet containing one allocation trace, one boundary translation, one permission failure, one TLB trace and one two-level walk. For each, write the initial state and assumptions before the result. Next week changes the resident-page assumption: what happens when the requested legal page has no immediately usable frame?

  1. Silberschatz, Galvin and Gagne, Operating System Concepts, 10th edition, Chapter 9: §9.1 Background; §9.2 Contiguous Memory Allocation; §9.3 Paging; §9.4 Structure of the Page Table; §9.5 Swapping. Architecture examples in §§9.6–9.7 are contextual references. Adapted explanations and original figures are credited throughout. Official slide source.
  2. Mehmet Göktürk, historical BIL601 memory-management lecture: segmentation hardware and example figures, adapted from the textbook tradition. Historical platform details are distinguished from current implementation claims.
  3. Arpaci-Dusseau and Arpaci-Dusseau, OSTEP: Paging: Introduction, Paging: Faster Translations, and Paging: Smaller Tables.
  4. Linux kernel: Page Tables; proc_pid_maps(5); sysconf(3). Implementation references checked during preparation, 21 October 2026.

Search CSE 513