作者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