[理工] OS process synchronization

看板Grad-ProbAsk作者 (code)時間14年前 (2011/11/29 00:25), 編輯推噓2(207)
留言9則, 4人參與, 最新討論串1/3 (看更多)
consider the following program boolean block[2]; int turn; void p(int id){ while(true) blocked[id]=true; while(trun!=id){ while(blocked[1-id]) do noop; turn = id; } /*critical section*/ block[id] = false; /*remainder section*/ } } void main() { blocked[0]=false; blocked[1]=false; turn = 0; parbegin(p(0),p(1)); } is mutual exclusion satisfied?! 我想問的是parbegin是什麼意思?! 是說直接從程式的某個部分開始跑嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.77.45.92

11/29 00:51, , 1F
雖然不知道是不是完整的code,不過parbegin感覺很像
11/29 00:51, 1F

11/29 00:51, , 2F
會執行兩個thread (Process) 之類的
11/29 00:51, 2F

11/29 00:52, , 3F
可以請教上面的Code是不是 bounded waiting 不成立?3Q
11/29 00:52, 3F

11/29 14:26, , 4F
mutual成立~bounded我覺得不成立
11/29 14:26, 4F

11/29 22:20, , 5F
本題只有問mutual exclusion,答案是不成立
11/29 22:20, 5F

11/29 22:22, , 6F
所以我才想說parbegin是不是直接跳到turn的後面一行去執行
11/29 22:22, 6F

11/29 22:23, , 7F
bounded waiting我也覺得不成立
11/29 22:23, 7F

11/29 22:54, , 8F
我覺得mutul跟progress都成立,bounded waiting不成立
11/29 22:54, 8F

11/29 22:57, , 9F
印象中parbegin是並行開始。
11/29 22:57, 9F
文章代碼(AID): #1EqxOAZE (Grad-ProbAsk)
文章代碼(AID): #1EqxOAZE (Grad-ProbAsk)