作者assassin88 (AI)
看板Grad-ProbAsk
標題Re: [理工] [OS]-paging 計算
時間Fri Jan 8 23:53:56 2010
※ 引述《assassin88 (...)》之銘言:
Consider the folling hardware configuration. Virtual address 32 bits, page
size 4KBytes, and a page table entry occupies 4Bytes. How many pages should
the OS allocate for the page tables of a 12MByte process under the folling
paging mechanisms?
(1)one-level paging.
(2)two-level paging.(Assume thar the number of entries in a first-level page
table is the same as that in a second-level table)
另外想請問,什麼是N-Step SCAN?
希望各位指導..感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.57.78.159
1F:推 converse2006:是在問page table需要的數量嗎? 如果是的話 12/24 01:30
2F:→ converse2006:one-level只有一張 two-level需要四張 page table 12/24 01:30
3F:→ converse2006:one-level page table entry數量=2^(32-12)=2^20 12/24 01:32
4F:→ converse2006:two-level page table entry數量2^((32-12)/2)=2^10 12/24 01:32
5F:→ converse2006:process所需page數 (12*2^20)/(4*2^10)=3*2^10 12/24 01:34
6F:→ converse2006:故one-level一張就放的下 two-level需要三張+第一層 12/24 01:35
7F:→ converse2006:有錯請告知^^" 12/24 01:35
8F:→ converse2006:只聽過SCAN/CSCAN Q_Q 12/24 01:36
9F:→ assassin88:答案是3跟4張..我算的你你的和他給的都不同Orz.. 12/24 09:40
10F:推 converse2006:第一個要三張 還蠻妙的..... 兩層都才只需要四張 12/25 00:57
11F:推 Jimmy0301:是三張應該沒錯,因為page size 4kbytes有十二個BITS 12/29 00:45
12F:→ Jimmy0301:為page offsets 則用20bits表示頁碼則有2^20個 12/29 00:46
13F:→ Jimmy0301:page entry 每個entry 4Bytes所以是4x2^20一張pagetable 12/29 00:47
14F:→ Jimmy0301:大小,再用12MB除以4x2^20就是三了 12/29 00:48
我今天跟同學借到答案,他是這樣寫的,看不太懂= =
page size = 2^12 bytes, process 大小為 12M = 3*2^22 bytes
所以 1個 page table 有 3*2^22 / 2^12 = 3*2^10 個 entries
→page table size = 3*2^10 * 2^2 = 3*2^12 bytes
→page table 須配置 3*2^12 / 2^12 = 3 pages.
麻煩解說一下..這題卡好久ˊˋ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.57.104.54
15F:推 polomoss:先算一個PT的size,再用Process佔的大小去除就好了 01/09 00:29
16F:→ polomoss:PT= 2^20 * 4Byte,Process=3* 2^22,相除得3 01/09 00:30
17F:→ assassin88:瞬間點破我的盲點~感謝 01/09 00:39