# Paging ## Basic * 允許process 在 physical address上的位置是不連續的 * logical memory → pages * physical memory → frames * Page number ( p ) * index of page table * Page offset ( d ) * equal to page size   * page的大小通常是2的冪次方 * If the <font color="orange">size of logical address space is 2^m^ </font> and <font color="orange">page size is 2^n^ addressing units</font> * logical address 的 * 前 $m-n$ bits 代表 page number * 後 $n$ bits 代表 page offset(page size)  * For a page table with <font color="orange">32-bit entry length</font> * 代表<font color="orange">最多可以有2^32^個frame</font> * 如果每個frame的大小為4KB * 那麼這個系統最多可以定 $2^{32} \times 2^{12} = 2^{44}$ bytes = 16TB 的 physical address ## Page summery * 越大的 page size 越容易發生 internal fragmentation * 每個process都有一個 page table * OS 維護一個 frame table 管理 physical memory * 每個frame都有一個entry * 指出frame的狀態(free or allocated) * 如果是allocated 則記錄 pid 和 page number :::info <font size=4px> :mega: when using paging : no external fragmentation some internal fragmentation</font> ::: ## Hardware Support 1. 使用暫存器 * 優點: 速度快 * 缺點: 僅用於小的 page table ,大部分的page table都很大 2. 將page table存在main memory中 * 利用PTBR記錄起始位址 * 利用PTLR記錄page table大小 * 優點: 用於page table較大的情況 * 缺點: 速度慢、需要兩次memory access 3. 使用TLB保存部分常用的page table * 到TLB查詢有無對應的page number * Hit: 輸出frame起始位址 (memory access: 1) * Miss: 到記憶體中的page table查詢 (memory access: 2)  ## Page Protection ## Shared Page --- ##### last edit > [name=dot] [time=Sat, Jan 4, 2020 11:06 PM] [HOME PAGE](/bKDZoNkrT9SOBnTvY_aj2Q?edit) :page_facing_up: {%hackmd theme-dark %} ###### tags: `OS` `CSIE`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up