Previous chapter
How to Go Beyond Physical Memory
32λΉνΈ μ΄λλ μ±μ νλ€
β νλ‘μΈμ€λ§λ€ 4GBλ§νΌμ VAκ° μκΈ΄λ€.
μ΄λκΉμ§λ νλ‘μΈμ€μ νμν νμ΄μ§κ° νΌμ§μ»¬ λ©λͺ¨λ¦¬μ λͺ¨λ νμΉνλ€κ³ κ°μ νλ€.
κ·Έλ¬λ νμ€μ λ λμ μ΄λλ μ€ μ€νμ΄μ€λ₯Ό μ§μν΄μΌνλ©°, μ΄λ₯Ό μν΄ OSκ° λ©λͺ¨λ¦¬ κ³μΈ΅ ꡬ쑰μ μλ‘μ΄ λ 벨μ λμ
ν΄μΌνλ€.
λ§μ½ λ©λͺ¨λ¦¬κ° λΆμ‘±ν΄ νλ‘μΈμ€λ₯Ό μ£½μΈλ€λ©΄ μμ²λ λ°λ°μ΄ μΌμ΄λ κ²μ΄λ€.
λ°λΌμ μ§κΈ λ΄κ° νμν λΆλΆλ€μ λν΄μ λ©λͺ¨λ¦¬κ° μλ νμμ μΌλ‘ λ λ§ν 곡κ°μ κ°μ΄ μ¨μΌνλ€.
β μ΄κ² λ°λ‘ λμ€ν¬.
Swap Space
κ°μ₯ λ¨Όμ ν μΌμ λμ€ν¬μ νμ΄μ§λ₯Ό μ μ₯ν μ μλ μΌμ 곡κ°μ ν보νλ κ².
Present Bit
λμ€ν¬μ μ€μ 곡κ°μ ν보νμΌλ μ΄μ νμ΄μ§ μ€μμ μν κΈ°λ₯μ λ€λ£° μ°¨λ‘.
μ΄λ€ λμ΄ λ©λͺ¨λ¦¬μ μκ³ μ΄λ€ λμ΄ λμ€ν¬μ μλμ§ νμΈν΄μΌ νλ€. β Address Translationμ μ λλ‘ νκΈ° μν μ₯μΉ
Page Fault
Page Fault Control Flow
Hardware
VPN = (VirtualAddress & VPN_MASK) >> SHIFT
(Success, TlbEntry) = TLB_Lookup(VPN)
if (Success == True) // TLB Hit
if (CanAccess(TlbEntry.ProtectBits) == True)
Offset = VirtualAddress & OFFSET_MASK
PhysAddr = (TlbEntry.PFN << SHIFT) | Offset
Register = AccessMemory(PhysAddr)
else
RaiseException(PROTECTION_FAULT)
else // TLB Miss
PTEAddr = PTBR + (VPN * sizeof(PTE))
PTE = AccessMemory(PTEAddr)
if (PTE.Valid == False)
RaiseException(SEGMENTATION_FAULT)
else
if (CanAccess(PTE.ProtectBits) == False)
RaiseException(PROTECTION_FAULT)
else if (PTE.Present == True)
// assuming hardware-managed TLB
TLB_Insert(VPN, PTE.PFN, PTE.ProtectBits)
RetryInstruction()
else if (PTE.Present == False)
RaiseException(PAGE_FAULT)
C
볡μ¬
Software
PFN = FindFreePhysicalPage()
if (PFN == -1) // no free page found
PFN = EvictPage() // run replacement algorithm
DiskRead(PTE.DiskAddr, PFN) // sleep (waiting for I/O)
PTE.present = True // update page table with present
PTE.PFN = PFN // bit and translation (PFN)
RetryInstruction() // retry instruction
C
볡μ¬
Page Replacement
Next chapter