看板 Grad-ProbAsk 關於我們 聯絡資訊
※ 引述《bernachom (Terry)》之銘言: : 請教一下.. : consider the following hardware configuration virtual address =32 bits, : page size=4kbytes, and a page table entry occupies 4 bytes. : How many pages should the OS allocate for the pages table of a 12Mbyte process : under the following paging mechanisms? : a)one-level paging : b)two-level paging.(assuming that the number of entries in a first-level : page table is the same as that in a second-level page table) : ---- : a)這題我是這樣算,2^20 * 4 = 4MB, 12MB/4MB=3個page table : b)算出來答案很怪... : 請教一下,b)這題要怎麼算呢? : 謝謝幫忙 ※更正一下,換個想法看看 a) 12MB/4KB = 3K (代表這個process需要3K個page→代表PT需要3K個entry) →再來計算 3K * 4byte = 12KB (代表這3K個entry佔12KB) →12KB / 4KB = 3 (總共需要3個page) b) 12MB /4KB =3K →因為現在變成 2-level,所以第二層的PT只能貢獻2^10個entry →由a知該Process需要3K個page →3K / 2^10 = 3 (代表第二層需要3個page) →還需要一個第一層對到第二層 →3 + 1 = 4 盡量寫的比較完整 -- ◤ ◥◤ ◥◤ ◥◤ ◥ Σ ◆ ◆ Σ ◆ ◆ Σ ◆ ◆ Σ ◆ ◆ ++++++ ++++++ ++++++++++++◥▇▆@ @▆▇◤ Ψ Ψ ▄▄▄ ▄▄▄ / \ ΓVISS -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.14.2
bernachom:其實我有點搞不太清楚,是要算page還是page table.. 03/02 14:11
bernachom:如果b)問的是要算page table數的話,那要怎麼算呢? 03/02 14:12
bernachom:然後你問的a)應該是給4MB,所以才會有內部碎裂的問題.. 03/02 14:13
lightergogo:要算page 03/02 14:16
polomoss:改一下~我寫錯了 03/02 14:20
※ 編輯: polomoss 來自: 122.116.14.2 (03/02 14:38)
polomoss:這樣想法應該才是對的,這樣就不會扯到virtual address 03/02 14:41
lightergogo:yes 03/02 14:44
polomoss:比較難想的是,第一層為何不用2^20去除 03/02 14:47
polomoss:因為該Process不會用到整個virtual addr.可表現的最大值 03/02 14:47
polomoss:想法有錯請更正 03/02 14:47
bernachom:了解,謝謝嚕^^ 03/02 14:48