20-ch9_part3
20-ch9_part3
Fall Semester
Operating Systems
Dr. Wafaa Samy
Dr. Hanaa Eissa
Background
Contiguous Memory Allocation
Segmentation
Paging (Cont.)
Swapping
Answer:
For given logical address space 2m and page size 2n
# of pages= # of entries = ? m -n n
Size of logical address space = 2m = # of pages × page size
m = 32
232 = # of pages × 212
page size = 4 KB = 4 × 210
# of pages =232 / 212= 220 pages = 22 × 210 = 212
n = 12
Operating System Concepts – 10th Edition
Silberschatz, Galvin and Gagne ©2018 9.5 Modified by Dr. Wafaa Samy
Implementation of Page Table
Page table is kept in main memory:
• Page-table base register (PTBR) points to the page table.
• Page-table length register (PTLR) indicates size of the page table.
In this scheme every data/instruction access requires two memory
accesses:
page number page offset
1. One for the page table and p d
2. one for the data / instruction. m -n n
The two-memory access problem can be solved by the use of a special
fast-lookup hardware cache called translation look-aside buffers (TLBs)
(also called associative memory parallel search).
Page # Frame #
• TLBs typically small (64 to 1,024 entries).
Logical address translation (p, d):
• If p is in associative register, get frame # out.
• Otherwise, get frame # from page table in memory.
On a TLB miss, value is loaded into the TLB for faster access next time:
• Replacement policies must be considered.
• Some entries can be wired down for permanent fast access.
Operating System Concepts – 10th Edition
Silberschatz, Galvin and Gagne ©2018 9.6 Modified by Dr. Wafaa Samy
Paging Hardware With TLB
With demand-paged virtual memory, pages are loaded only when they
are demanded during program execution. Pages that are never accessed
are thus never loaded into physical memory.
Similar to paging system with swapping.
Page is needed reference to it.
• invalid reference abort.
• not-in-memory bring to memory.
Lazy swapper – never swaps a page into memory unless page will be needed.
• Swapper that deals with pages is a pager.
Operating System Concepts – 10th Edition
Silberschatz, Galvin and Gagne ©2018 9.21 Modified by Dr. Wafaa Samy
Basic Concepts
With swapping, pager guesses which pages will be used before
swapping out again.
Instead, pager brings in only those pages into memory.
How to determine that set of pages?
• Need new MMU functionality to implement demand paging.
If pages needed are already memory resident.
• No difference from non demand-paging.
If page needed and not memory resident.
• Need to detect and load the page into memory from storage:
Without changing program behavior.
Without programmer needing to change code.
• While a process is
executing, some
pages will be in
memory, and some
will be in secondary
storage.
• Thus, we need some
form of hardware
support to
distinguish between
the two:
The valid–invalid
bit scheme can be
used for this
purpose.