Re: [理工] 計組問題請問
我覺得這題不是在講LRU,雖然LRU也是用counter。
因為LRU的想法,跟題目一開始所希望達成的想法根本不同。
而且你也沒有解釋,恐龍本完整題目問的其它問題? (如何增加、減少counter)
所以依我看,這題目只是一個天馬行空的演算法。
就是當frame 有page結合,counter = 1,否則counter = 0
為什麼說是天馬行空的演算法 ?
1. counter 竟然只有一開始frame是空的時候為0,其它是1
2. 這個演算法根本就是FIFO。完全不需要counter。
有錯請指正!
※ 引述《cormen5566 (風行者)》之銘言:
: ※ 引述《loeooo (籃球狂)》之銘言:
: : A page-replacement algo. minimizes the number of page faults by distributing
: : heavily used pages evenly over all of memory. It associates with each
: : page frame a counter of the number of pages that are associated with that
: : frame, and the initial value of the coounters is 0. Then, to replace a page,
: : it searches for the page frame with the smallest counter. The counters are
: : increased whenver a new page is associated with that frame; and are decreased
: : whenever one of the pages associated with that frame is no longer required.
: : a) How many page faults occur for the algo. for the following reference string,
: : for four page frames?
: : 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2.
: : 這題在說什麼啊? 不太懂意思?? 可以順便解個我看嗎? 解前幾個大概告訴我做法就好了
: : 謝謝!!
: 這題大致上講說,使用LRU的策略~
: 題目前半段大致上在講LRU用counter的作法
: 1 2 3 4 5 3 4 1 6 7 8 7 8 9 7 8 9 5 4 5 4 2
: ___________________________________________
: 1 1 1 1 5 5 6 6 6 6 5 5 5
: 2 2 2 2 1 1 1 1 9 9 9 9
: 3 3 3 3 3 7 7 7 7 4 4
: 4 4 4 4 4 8 8 8 8 2
: 共13次的page faults
: : b) what's the minimum number of page faults for an optimal page replacement
: : strategy for the reference string in part (a) with four page frames?
: : 這題是用最佳策略法嗎? 我算出來11次 不知道跟大家算的一不一樣耶??
: 1 2 3 4 5 3 4 1 6 7 8 7 8 9 7 8 9 5 4 5 4 2
: ___________________________________________
: 1 1 1 1 1 6 7 7 7 4 2
: 2 2 2 5 5 5 5 5 5 5
: 3 3 3 3 3 8 8 8 8
: 4 4 4 4 4 9 9 9
: 共11次page faults
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.166.28
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):