Академический Документы
Профессиональный Документы
Культура Документы
Paging Concepts
I
I
I
A Simple Example
of
of
of
of
page frames = 8
pages = 16
bits in physical address = 15
bits in virtual address = 16
[16k, 20k)
2
1
6
0
X
[20k, 24k)
[0, 4k)
[4k, 8k)
[8k, 12k)
[12k, 16k)
0
1
[0, 4k)
[4k, 8k)
[8k, 12k)
4
5
[12k, 16k)
[16k, 20k)
5
6
[24k, 28k)
[28k, 32k)
[20k, 24k)
absent pages
9
10
11
12
13
14
[60k, 64k)
Physical Address
Space
15
0 1
4bit page#
page table
010
001
110
1
1
000
1
011
...
1 0
1 0
20500
16bit virtual address
present/absent
bit
011000000010100
15bit physical address
12388
page size
4K
4K
252
number of pages
220 (about 1 million entries)
(about 4500 trillion entries!)
Multi-level Page Tables. Split the bits for the page number
in the virtual address into multiple fields (usually three or
four). The page table is then arranged as a multi-way tree
with each node in the tree being a small page table. Far less
memory requirements. Combined with a Translation
Lookaside Buffer (a cache for virtual to physical address
translations), this design gives good performance.
part2
pages
0
1
text
2
.
.
.
part1
0
10 bits
10 bits
12 bits
1
data
part1
part2
offset
1023
secondlevel
page tables
0
1023
heap
pages
.
.
.
1
2
.
.
.
toplevel
page table
1023
stack
.
.
.
pages
0
1
2
.
.
.
1023
Examples of Paging
11/2
hardware trap
save CPU state
switch to kernel
3
determine virtual address
that caused the fault
invalid
reference
check validity
restore state
valid
reference
found a clean
page frame
mark page
frame busy
found a dirty
page frame
interrupt
context switch
7
schedule transfer
of page we need
10
reschedule user
process to run
USER space
KERNEL Space
9
rollback
instruction
interrupt
Paging Algorithms
Random Replacement.
See http://en.wikipedia.org/wiki/Page_replacement_algorithm
for more details.
Use one bit per page which is periodically set to zero. Each
time the page is read from or written to, hardware
automatically sets the reference bit to one. Inexpensive,
though crude, implementation of LRU scheme.
Segmentation
10 bits
page number
12 bits
offset
Diagram from Operating System Concepts, 6th Ed. by Silberschatz and Galvin
I
I
I
Paging
1
Yes
No
No
No
No
Segmentation
>2
Yes
Yes
Yes
Yes
Yes