看板 Grad-ProbAsk 關於我們 聯絡資訊
suppose we have two processes with indices 0 and 1. Assume that count is a shared variable between the two processes with initial value zero. (Suppose count is implemented without limit in its range.) Also each process with index p has a local variable ticket[p] with initial value zero We have the following mutual-exclusion algorithm for the two processes in a distributed system. while(ture){ ticket[p] = count = count+1; while(ticket[1-p] != 0 && ticket[1-p] < ticket[p]); CS ticket[p] = 0; RS } 請問這分別滿足mutual exclusion, progress, bounded waiting嗎? 97台大電機 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.117.109 補充一下洪捷的解答 滿足mutual exclusion, bounded waiting 不滿足progress 請問這要怎麼判斷? 有高手會解這題嗎? 謝謝 ※ 編輯: mqazz1 來自: 140.118.110.186 (07/31 20:53)
wheels:count = count + 1 不能保證一步完成 若兩個processes都先 08/01 00:37
wheels:做+ 兩個再做assign則抓到的ticket值都一樣 08/01 00:38
wheels:等等...真的是因為不滿足progress嗎...? 08/01 00:49
wheels:我反而覺得是mutual exclusion出問題 08/01 00:57
其實我一開始也是覺得mutual exclusion不滿足 其他兩個滿足= = 我已經把回文都看完了 題目的確是少打了atomic.. 感謝大家的回覆 ※ 編輯: mqazz1 來自: 140.118.110.186 (08/01 10:03)
wheels:對不起,睡個覺起來後發現我解錯了,B大是正確的! 08/01 12:51