Re: [理工] [OS] race condition

看板Grad-ProbAsk作者 (單戈示申)時間14年前 (2012/03/13 21:19), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串1/1
因為題目敘述有三個process執行 所以可以分成下面這種情況來討論 P1 P2 P3 ------------------------------ T1:x=y T2:x=y T3:x=y T4:x=x+1 T5:x=x+1 T6:x=x+1 T7 :y=x T8 :y=x T9 :y=x 若要y=2 則依照下面的順序執行即可 T1 T4 T7 T2 T3 T5 T6 T8 T9 有錯請指證! ※ 引述《wsx02 ()》之銘言: : shared y; : begin : local x; : x = y; : x = x+1; : y = x; : end : if local variable x and shared variable y initially 0 and three copies of the : process run concurrently. What is the possible values of y after three copies : of the process terminate? : y的可能值有2 : 請問是怎麼跑出來的? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.169.104.4

03/13 21:28, , 1F
x是local variable 我照這樣的順序出來y=1 可以請問細節嗎?
03/13 21:28, 1F

03/13 21:29, , 2F
我造出來了
03/13 21:29, 2F

03/13 21:30, , 3F
順序是T1 T2 T4 T5 T7 T8 T3 T6 T9 謝謝
03/13 21:30, 3F
噢 沒注意到是local 感謝指證! ※ 編輯: Fight5566 來自: 118.169.104.4 (03/13 21:34)
文章代碼(AID): #1FNqbaq_ (Grad-ProbAsk)