CS330 · Chapter 8 · Annotated SlidesMemory Management
Original
Overview

Memory Management

Address binding, logical vs. physical addresses and the MMU, swapping, contiguous allocation (first, best and worst fit) and fragmentation, segmentation, paging and address translation, the TLB and effective access time, protection and shared pages.

How to read this page

Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.

All 45 slides
  1. 1 Slide 1
  2. 2 In this lecture, we will discuss the following:
  3. 3 Program must be brought into memory and placed within a process
  4. 4 Address binding of instructions and data to memory
  5. 5 Slide 5
  6. 6 The concept of a logicaladdress space that is bound to a separate
  7. 7 Slide 7
  8. 8 MMU is a HW device that maps virtual to physical address.
  9. 9 A process can be swapped temporarily out of memory to a
  10. 10 Slide 10
  11. 11 ➢ If next processes to be put on CPU is not in memory, need to swap
  12. 12 ➢ Main memory must support both OS and user processes
  13. 13 Slide 13
  14. 14 ➢ Multiple-partition allocation
  15. 15 Slide 15
  16. 16 A variable partition memory system has the following hole sizes:
  17. 17 Both the first-fit and best-fit strategies for memory allocation suffer from
  18. 18 Solutions
  19. 19 Do programmers think of memory as a
  20. 20 Memory-management scheme that supports user view of memory.
  21. 21 Slide 21
  22. 22 Logical address consists of a two tuple:
  23. 23 Slide 23
  24. 24 Slide 24
  25. 25 • Consider the following segment table:
  26. 26 Slide 26
  27. 27 ➢ Paging allows the physical address space of a process to be non-
  28. 28 ➢ Address generated by CPU is divided into:
  29. 29 Slide 29
  30. 30 Slide 30
  31. 31 Slide 31
  32. 32 Consider a logical address space of 256 pages with a 4-KB page size, mapped onto
  33. 33 Consider that the physical memory is 256K, logical memory (per process) is 64K
  34. 34 Slide 34
  35. 35 Page-tablebase register ( PTBR) points to the page table.
  36. 36 Associative registers
  37. 37 Slide 37
  38. 38 ➢ Effective access time (EAT) is the average time needed to access
  39. 39 A paging scheme uses a Translation Look-aside Buffer (TLB).
  40. 40 A paging scheme uses a Translation Look-aside Buffer (TLB).
  41. 41 Memory protection in a paged environment is implemented by
  42. 42 Slide 42
  43. 43 Shared code
  44. 44 Slide 44
  45. 45 and/or segments must be loaded
Slide 1 / 45

Slide 1

Slide 1: Slide 1
Slide 2 / 45

In this lecture, we will discuss the following:

Slide 2: In this lecture, we will discuss the following:
Slide 3 / 45

Program must be brought into memory and placed within a process

Slide 3: Program must be brought into memory and placed within a process
Slide 4 / 45

Address binding of instructions and data to memory

Slide 4: Address binding of instructions and data to memory
Slide 5 / 45

Slide 5

Slide 5: Slide 5
Slide 6 / 45

The concept of a logicaladdress space that is bound to a separate

Slide 6: The concept of a logicaladdress space that is bound to a separate
Slide 7 / 45

Slide 7

Slide 7: Slide 7
Slide 8 / 45

MMU is a HW device that maps virtual to physical address.

Slide 8: MMU is a HW device that maps virtual to physical address.

Notes

  1. MMU maps logical to physical at run time; simplest form adds the relocation (base) register.

Exam angle

PredictionQ1

With relocation register 14000, logical address 346 maps to:

Slide 9 / 45

A process can be swapped temporarily out of memory to a

Slide 9: A process can be swapped temporarily out of memory to a

Notes

  1. Swapping: move a process temporarily to a backing store and back. Transfer time dominates.

Slide 10 / 45

Slide 10

Slide 10: Slide 10
Slide 11 / 45

➢ If next processes to be put on CPU is not in memory, need to swap

Slide 11: ➢ If next processes to be put on CPU is not in memory, need to swap
Slide 12 / 45

➢ Main memory must support both OS and user processes

Slide 12: ➢ Main memory must support both OS and user processes
Slide 13 / 45

Slide 13

Slide 13: Slide 13
Slide 14 / 45

➢ Multiple-partition allocation

Slide 14: ➢ Multiple-partition allocation
Slide 15 / 45

Slide 15

Slide 15: Slide 15

Exam angle

PredictionQ1

Holes: 100, 500, 200, 300, 600 KB. Best fit places a 212 KB request in:

PredictionQ2

Same holes; first fit places 212 KB in:

Slide 16 / 45

A variable partition memory system has the following hole sizes:

Slide 16: A variable partition memory system has the following hole sizes:
Slide 17 / 45

Both the first-fit and best-fit strategies for memory allocation suffer from

Slide 17: Both the first-fit and best-fit strategies for memory allocation suffer from
Slide 18 / 45

Solutions

Slide 18: Solutions

Notes

  1. Trap Paging has NO external fragmentation but can have internal fragmentation in the last page.

Exam angle

PredictionQ1

Paging eliminates:

Slide 19 / 45

Do programmers think of memory as a

Slide 19: Do programmers think of memory as a
Slide 20 / 45

Memory-management scheme that supports user view of memory.

Slide 20: Memory-management scheme that supports user view of memory.
Slide 21 / 45

Slide 21

Slide 21: Slide 21
Slide 22 / 45

Logical address consists of a two tuple:

Slide 22: Logical address consists of a two tuple:
Slide 23 / 45

Slide 23

Slide 23: Slide 23

Notes

  1. Segment table has base and limit; offset d must be < limit, else trap. Physical = base + d.

Slide 24 / 45

Slide 24

Slide 24: Slide 24
Slide 25 / 45

• Consider the following segment table:

Slide 25: • Consider the following segment table:

Notes

  1. Segment-table exercise: check d < limit first, then add base.

Exam angle

PredictionQ1

Segment 0 has base 219, limit 600. Translate (0, 430) and (0, 700).

Compare with the model answer

(0, 430): 430 < 600 → physical 219 + 430 = 649. (0, 700): 700 ≥ 600 → addressing error (trap).

Slide 26 / 45

Slide 26

Slide 26: Slide 26
Slide 27 / 45

➢ Paging allows the physical address space of a process to be non-

Slide 27: ➢ Paging allows the physical address space of a process to be non-
Slide 28 / 45

➢ Address generated by CPU is divided into:

Slide 28: ➢ Address generated by CPU is divided into:

Notes

  1. Logical address = page number p (high m − n bits) + offset d (low n bits) for page size 2ⁿ and logical space 2ᵐ.

Exam angle

PredictionQ1

With 4 KB pages, how many bits are the page offset?

Slide 29 / 45

Slide 29

Slide 29: Slide 29
Slide 30 / 45

Slide 30

Slide 30: Slide 30
Slide 31 / 45

Slide 31

Slide 31: Slide 31
Slide 32 / 45

Consider a logical address space of 256 pages with a 4-KB page size, mapped onto

Slide 32: Consider a logical address space of 256 pages with a 4-KB page size, mapped onto

Notes

  1. Exercise: logical space 256 pages × 4 KB = 2²⁰ → 20-bit logical address (8-bit page number + 12-bit offset).

Exam angle

PredictionQ1

256 pages of 4 KB each need a logical address of:

Slide 33 / 45

Consider that the physical memory is 256K, logical memory (per process) is 64K

Slide 33: Consider that the physical memory is 256K, logical memory (per process) is 64K
Slide 34 / 45

Slide 34

Slide 34: Slide 34
Slide 35 / 45

Page-tablebase register ( PTBR) points to the page table.

Slide 35: Page-tablebase register ( PTBR) points to the page table.

Notes

  1. Page table in memory (PTBR, PTLR) means two memory accesses per reference; the TLB (associative cache) fixes this.

Slide 36 / 45

Associative registers

Slide 36: Associative registers
Slide 37 / 45

Slide 37

Slide 37: Slide 37
Slide 38 / 45

➢ Effective access time (EAT) is the average time needed to access

Slide 38: ➢ Effective access time (EAT) is the average time needed to access

Exam angle

PredictionQ1

TLB 20 ns, memory 100 ns, hit ratio 80%. EAT =

Slide 39 / 45

A paging scheme uses a Translation Look-aside Buffer (TLB).

Slide 39: A paging scheme uses a Translation Look-aside Buffer (TLB).
Slide 40 / 45

A paging scheme uses a Translation Look-aside Buffer (TLB).

Slide 40: A paging scheme uses a Translation Look-aside Buffer (TLB).
Slide 41 / 45

Memory protection in a paged environment is implemented by

Slide 41: Memory protection in a paged environment is implemented by

Notes

  1. Protection: a valid–invalid bit per page-table entry; also read/write/execute bits.

Slide 42 / 45

Slide 42

Slide 42: Slide 42
Slide 43 / 45

Shared code

Slide 43: Shared code
Slide 44 / 45

Slide 44

Slide 44: Slide 44
Slide 45 / 45

and/or segments must be loaded

Slide 45: and/or segments must be loaded