[理工] 103台大電機計結 第5題
http://imgur.com/a/IyaTs
這題困擾我好久,不過版上竟然只有一篇在討論
(a)使用Write allocate+Write through
Read hit:我一開始看到就有個疑問,CPU和Cache之間資了傳輸為什麼不用算到bus裡?這
題的解答bus使用量似乎只有算CPU和Memory, Memory和Cache之間的資料傳輸量
Read miss:要去Memory讀資料,每次讀一個block=4 words這我ok
Wrtie hit:採用wrtie throguh更新Cache和memory,為什麼每次只要更新1 word? 為什麼
不是每次更新1 block=4 words?
Wrtie miss:採用write allocate, 要從memory把block搬到cache,再寫入cache,同樣的
,這邊搬block要花4 words,但是寫入cache只有1 word?而且這邊如果寫入cache要花1 word
,那為什麼Read hit的時候從cache 班資料到CPU就不用佔用bus bandwidth?(還有write hit
時同時寫入cache和memory只要花1 word? 如果這邊寫入cache要花1 word,同時寫入cache和
memory應該要花2 words吧,假設一次只寫1 word的話)
(b)同(a)只是改數字
__________________________________________________________________________
(c)(d)(e)相同使用write through+write back
Read hit:同(a)的疑問,CPU和cache之間傳輸不用佔bus bandwidth 嗎?
以下都沒問題,寫出來讓大家參考
Read miss:要先把dirty的block(4 words)移回memory(花0.3*4 words),再把要讀出來的
block(4 words)送到CPU(從memory)這邊OK
write hit:用write back,僅更改cache block,並將dirty bit=1, 不用寫入memory , bandwidth=0
write miss:用wirte allocate,將memory 的一個block(4 words)搬到cache,並且同write
hit,所以只要花4 words
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.105
※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1484383235.A.C57.html
→
01/14 16:43, , 1F
01/14 16:43, 1F
→
01/14 16:44, , 2F
01/14 16:44, 2F
→
01/14 16:46, , 3F
01/14 16:46, 3F
→
01/14 17:13, , 4F
01/14 17:13, 4F
→
01/14 17:15, , 5F
01/14 17:15, 5F
→
01/14 17:15, , 6F
01/14 17:15, 6F
→
01/14 17:15, , 7F
01/14 17:15, 7F
原來如此
→
01/14 17:33, , 8F
01/14 17:33, 8F
→
01/14 17:35, , 9F
01/14 17:35, 9F
似乎是,我看100清大寫說:Because we have write through policy we have to write to main memory on every hit. But we have to write only 1 word.
※ 編輯: Transfat (140.112.25.105), 01/14/2017 17:41:35
→
01/14 17:44, , 10F
01/14 17:44, 10F
聽說這樣子才是會考得好的前兆,如果覺得自己都會的人通常都(?)
→
01/14 17:47, , 11F
01/14 17:47, 11F
→
01/14 17:48, , 12F
01/14 17:48, 12F
→
01/14 17:48, , 13F
01/14 17:48, 13F
→
01/14 17:50, , 14F
01/14 17:50, 14F
謝謝ken和yu,我搞懂這題了。
※ 編輯: Transfat (140.112.25.105), 01/14/2017 17:52:20
推
01/14 20:54, , 15F
01/14 20:54, 15F
→
01/14 20:54, , 16F
01/14 20:54, 16F
→
01/14 20:54, , 17F
01/14 20:54, 17F
→
01/14 20:54, , 18F
01/14 20:54, 18F
這是個好問題,什麼時候要把dirty block寫回memory,網路上幾乎都只說當系統有空的時
候或是有其他使用率更高的address要來取代,或是講一些模稜兩可的話:The data in these locations are written back to the backing store when those data are evicted from the cache. 而103台大電機的答案和100清大的答案都說要在Read miss的時候把dirty block寫回memory. 所以我們就姑且相信他吧
※ 編輯: Transfat (140.112.25.105), 01/14/2017 21:49:28
※ 編輯: Transfat (140.112.25.105), 01/14/2017 21:49:52
※ 編輯: Transfat (140.112.25.105), 01/14/2017 21:50:33
推
01/14 22:06, , 19F
01/14 22:06, 19F
→
01/14 22:06, , 20F
01/14 22:06, 20F
→
01/14 22:06, , 21F
01/14 22:06, 21F
→
01/14 22:06, , 22F
01/14 22:06, 22F
→
01/14 22:06, , 23F
01/14 22:06, 23F
有道理,可是台大的老師似乎不是這樣想?因為台大這題是出write allocate+wrtie back,
也沒有在write miss的時候寫回dirty block
推
01/14 23:05, , 24F
01/14 23:05, 24F
推
01/14 23:21, , 25F
01/14 23:21, 25F
→
01/14 23:22, , 26F
01/14 23:22, 26F
哇這個解答覺得write miss和read miss都要寫回dirty block
推
01/14 23:26, , 27F
01/14 23:26, 27F
→
01/14 23:27, , 28F
01/14 23:27, 28F
的確,因為wrtie through和write allocate一起用很怪,都已經在miss的時候把block搬
到cache了,結果寫入又要一併寫回memory,有種多此一舉的感覺
→
01/14 23:28, , 29F
01/14 23:28, 29F
推
01/14 23:37, , 30F
01/14 23:37, 30F
→
01/14 23:37, , 31F
01/14 23:37, 31F
→
01/14 23:38, , 32F
01/14 23:38, 32F
※ 編輯: Transfat (140.112.25.105), 01/15/2017 14:56:03
※ 編輯: Transfat (140.112.25.105), 01/15/2017 15:00:18
推
01/29 22:10, , 33F
01/29 22:10, 33F
→
01/29 22:10, , 34F
01/29 22:10, 34F
→
01/29 22:10, , 35F
01/29 22:10, 35F