Re: [理工] [計組] 99台大
面對多核cpu來說 各個cpu都會有自己的cache
不過各個cpu對自己的cache做更新的同時
其他cpu不知道cache裡位於同一個block的資料已經被改過了
於是就會有資料錯誤的情形 所以就會出現cache coherence問題
通常有兩種解決方式 這兩種就是題目問的7(a)與7(b)
7(a)的意思是說進行寫入的cpu(A)在改變自己cache的資料時
會將其他cpu裡的copy都設為無效 (invalidate)
若cpu(B)裡要對這個無效的block作read/write時一定會miss
則會place read/write miss on bus
cpu(A)收到這個signal則會將cache資料write back至memory
cpu(B)再從memory抓資料時就會是最新資料了
故通常write-invalidate都搭配write back使用
用講的有點複雜 最好看書本上的FSM diagram去跑一次所有情況了解比較好
7(b)的意思是進行寫入的cpu在改變自己cache資料時
除了將自己資料更新 並且也廣撥此最新的資料到其他cpu的cache並更新
所以全部的cache都有最新資料
通常搭配write through使用
解這類題目通常列表格會比較快速 雖然比較麻煩 但是也比較清楚
注意這時題意說每個processor的cache只有一個block
所以各個cache需要一格就夠了
block d 都沒用到就不寫了
7(a) P1 P2 P3 Memory
cache1 cache2 cache3 a b c
1.P1:read(a) 10(a) . . 10 20 40
2.P2:read(a) 10(a) 10(a) . 10 20 40
3.P3:read(a) 10(a) 10(a) 10(a) 10 20 40
4.P1:a=a+20 30(a) 10(a)x 10(a)x 10 20 40
5.P1:read(c) 40(c) 10(a)x 10(a)x 30 20 40 (30wb)
6.P2:read(a) 40(c) 30(a) 10(a)x 30 20 40
7.P3:a=15 40(c) 30(a)x 15(a) 30 20 40
8.P1:c=c+10 50(c) 30(a)x 15(a) 30 20 40
7(b) P1 P2 P3 Memory
cache1 cache2 cache3 a b c
1.P1:read(a) 10(a) . . 10 20 40
2.P2:read(a) 10(a) 10(a) . 10 20 40
3.P3:read(a) 10(a) 10(a) 10(a) 10 20 40
4.P1:a=a+20 30(a) 30(a) 30(a) 30 20 40
5.P1:read(c) 40(c) 30(a) 30(a) 30 20 40
6.P2:read(a) 40(c) 30(a) 30(a) 30 20 40
7.P3:a=15 40(c) 15(a) 15(a) 15 20 40
8.P1:c=c+10 50(c) 15(a) 15(a) 15 20 50
大概是這樣 有錯請更正@@
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.115.13
※ 編輯: qwertz 來自: 118.160.115.13 (03/10 04:38)
推
03/10 08:09, , 1F
03/10 08:09, 1F
推
03/10 13:04, , 2F
03/10 13:04, 2F
※ 編輯: qwertz 來自: 118.160.113.196 (03/10 17:31)
推
03/10 22:41, , 3F
03/10 22:41, 3F
打錯 已更正 謝謝~
推
03/10 23:02, , 4F
03/10 23:02, 4F
→
03/10 23:02, , 5F
03/10 23:02, 5F
→
03/10 23:03, , 6F
03/10 23:03, 6F
※ 編輯: qwertz 來自: 118.160.113.196 (03/11 02:02)
→
03/11 02:03, , 7F
03/11 02:03, 7F
→
03/11 02:04, , 8F
03/11 02:04, 8F
推
03/13 21:29, , 9F
03/13 21:29, 9F
推
02/08 19:12, , 10F
02/08 19:12, 10F
討論串 (同標題文章)