Professional Documents
Culture Documents
Chapter 9
Main Memory
high
memory
low
memory
할당 o
2번씩 접근
TLB에 들어있는지 확인
TLB에 의해 알아낸 번호로 hit
Paging Hardware With TLB 메인메모리 1번 접근
TLB miss가 일어나면 페이지
테이블을 찾아감.
페이지와 프레임 번호를 TLB에
복사를 해놈(page table)
저장
페이지 테이블에 대한 캐시 역할
메인메모리 안에 있음
Implementation of Page Table 2
◆ Associative memory – parallel search
◆ Address translation (p, d)
➢ If p is in associative register, get frame # out
➢ Otherwise get frame # from page table in memory
◆ TLBs typically small (64 to 1,024 entries). TLB contains only a few
of the page-table entries.
◆ On a TLB miss, value is loaded into the TLB for faster access next
time
➢ Replacement policies must be considered(LRU, RR, ….)
➢ Some entries can be wired down for permanent fast access
◆ Some TLBs store address-space identifiers (ASIDs) in each TLB
entry – uniquely identifies each process to provide address-space
protection for that process 이게 없으면 매번 페이지 프레임 번호를 바꿔야 함.
➢ Otherwise need to flush at every context switch
Effective Access Time
◆ Associative memory lookup time =
◆ memory cycle time = 1
◆ Hit ratio = TLB에 들어있을 확률
➢ percentage of times that a page number is found in the associative
registers; ratio related to number of associative registers
◆ Effective Access Time (EAT)
= (1 + ) + (2 + )(1 – )
◆ Consider = 80%, 0ns for TLB search, 10ns for memory access
➢ EAT = 0.80 x 10 + 0.20 x 20= 12ns
◆ Consider = 99%, = 0ns for TLB search, 10ns for memory access
➢ EAT = 0.99 x 10 + 0.01 x 20 = 10.1ns
Memory Protection
◆ Memory protection implemented by associating protection bit with
each frame to indicate if read-only or read-write access is allowed
➢ Can also add more bits to indicate page execute-only, and so on
◆ Valid-invalid
Valid-invalid bit attached to each entry in the page table:
➢ “valid” indicates that the associated page is in the process’ logical
address space, and is thus a legal page
➢ “invalid” indicates that the page is not in the process’ logical address
space
➢ Or use page-table length
page-table register
length (PTLR)
register (PTLR)
◆ Any violations result in a trap to the kernel
Valid(v) / Invalid(i) Bit in a Page Table
◆ Ex: 14-bit address space (0~16383)
➢ program use only address 0~10468
➢ page size 2KB
Shared Pages
◆ Shared code
➢ One copy of read-only (reentrant) code shared among processes (i.e.,
text editors, compilers, window systems)
➢ Similar to multiple threads sharing the same process space
➢ Also useful for interprocess communication if sharing of read-write
pages is allowed
◆ Private code and data
➢ Each process keeps a separate copy of the code and data
➢ The pages for the private code and data can appear anywhere in the
logical address space
페이지 테이블을 이용해서 중복되는
Shared Pages Example 것을 방지해줌
Structure of the Page Table
◆ Memory structures for paging can get huge using straight-forward
methods
➢ Consider a 32-bit logical address space
➢ Page size of 4 KB (212)
➢ Page table would have 1M entries (232 / 212)
➢ If each entry is 4 bytes -> 4 MB of physical address space / memory for
page table alone
✓ Don’t want to allocate that contiguously in main memory
◆ Hierarchical
Hierarchical Paging
Paging
◆ Hashed
HashedPage Tables
Page Tables
◆ Inverted
Inverted Page Tables
Page Tables
Hierarchical Paging
◆ Break up the logical address space into multiple page tables
◆ A simple technique is a two-level page table
◆ We then page the page table
Two-Level Page-Table Scheme
logical address
Address-Translation
for two-level 32-bit page-table scheme
Two-Level Paging Example
◆ A logical address (on 32-bit machine with 4K page size) is divided
into:
➢ a page number consisting of 20 bits
➢ a page offset consisting of 12 bits
◆ Since the page table(each entry in page table: 4B) is paged, the
page number is further divided into:
➢ a 10-bit page number
➢ a 10-bit page offset
◆ Thus, a logical address is as follows:
➢ But in the following example the 2nd outer page table is still 234 bytes in size
✓ And possibly 4 memory access to get to one physical memory location
Hashed Page Tables 시간 절약이 중요!
frame number
page number
Swapping
◆ A process can be swapped temporarily out of memory to a backing
store, and then brought back into memory for continued execution
◆ (+) Total physical memory space of all processes can exceed
physical memory ➔ increase degree of multiprogramming
◆ Backing store
➢ fast disk large enough to accommodate copies of all memory images for
all users
➢ must provide direct access to these memory images
Standard Swapping
◆ Moving entire processes between main memory and a backing store
◆ When a process is swapped out, data structures associated with
process must be written to backing store and can be restored when
swapped in.
◆ Idle processes are
candidates for swapping
◆ Generally no longer
used in contemporary
OS, because of the
amount of time required
to move entire
processes
Swapping with Paging
◆ Most systems(Linux,
Windows) now use a
variation of swapping in
which pages of a process
can be swapped
◆ paging refers to
swapping with paging
◆ page page in
page out & page in