
: logical memory address space와 physical memory address space의 분리,
logical memory address space는 physical memory address space보다 클 수 있음

(memory 꽉찼을 때 밀어내는거 : swapping)


VPN = (VirtualAddress & VPN_MASK) >> SHIFT
// VPN 추출
(Success, TlbEntry) = TLB_Lookup(VPN)
// 추출한 VPN에 대한 주소 변환 정보가 TLB에 있는지 확인
if (Success == True)
// TLB에 있으면
if (CanAccess(TlbEntry.ProtectBits) == True)
Offset = VirtualAddress & OFFSET_MASK
PhysAddr = (TlbEntry.PFN << SHIFT) | Offset
Register = AccessMemory(PhysAddr)
else RaiseException(PROTECTION_FAULT)
else
// TLB에 없으면
PTEAddr = PTBR + (VPN * sizeof(PTE))
// Page Table에 접근해 page위치 알아옴
PTE = AccessMemory(PTEAddr)
if (PTE.Valid == False)
RaiseException(SEGMENTATION_FAULT)
else
if (CanAccess(PTE.ProtectBits) == False)
RaiseException(PROTECTION_FAULT)
else if (PTE.Present == True)
// Present bit가 True라면 (메모리에 page table 존재)
TLB_Insert(VPN, PTE.PFN, PTE.ProtectBits)
RetryInstruction()
else if (PTE.Present == False)
// Present Bit가 False라면 (Swap 공간에 page table 존재)
RaiseException(PAGE_FAULT)
// Page Fault 발생
PFN = FindFreePhysicalPage()
// Page 가지고 와서 할당할 메모리 공간을 찾음
if (PFN == -1)
PFN = EvictPage()
DiskRead(PTE.DiskAddr, PFN)
// disk에서 page table 데이터를 가지고 옴
PTE.present = True
// Present Bit를 True로 수정
PTE.PFN = PFN
RetryInstruction()