Try   HackMD

Ch18 Paging

這一章是《Operating Systems: Three Easy Pieces》的第 18 章,主題是 Paging: Introduction(分頁:簡介),目的是介紹一種在現代作業系統中非常常見的 記憶體虛擬化方法。

Intro

  • 早期使用 segmentation 把記憶體切成不同大小的 segment,容易產生 external fragmentation
  • Paging:把記憶體切成固定大小的區塊
    • Virtual memory -> pages
    • Physical memory -> frames
  • 好處:
    • 防止 internal/external fragmentation
    • 讓 process 可以更靈活運用記憶體空間
      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →

Address translation

  • 把 virtual address 拆成
    • VPN:Virtual page 的編號
    • Offset:在 page 中的第幾個 byte
      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →
  • 利用 Page table 找出與 VPN 對應的 PFN
  • PFN + offset 找出 physical address
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

找到 PTE 在哪

  • PTE(Page table entry)
    • Page table 中用來記錄 VPN -> PFN 關係的表格
    • the number of PTE = the number of virtual page
  • PTBR(Page Table Base Register)
    • Page table 的 base
  • 找出 PTE 的公式
    • target PTE=PTBR+VPN×sizeof(PTE)
  • 整體流程:
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

問題

有些過程硬體的讀取速度較慢:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

  • 解決方案:使用 TLB(下一章內容)