作者chris750630 (goodness)
看板Grad-ProbAsk
標題Re: [理工] [OS] - critical section problem
時間Sat Aug 21 12:27:58 2010
※ 引述《nypgand1 (祈附‧征前御祭)》之銘言:
: var flag: array[0..1] of Boolean; (initailly false)
: turn: 0..1; (initailly 1)
: The following program is for process Pi (i = 0 or 1),
: with Pj (j = 1 or 0) being the other process
: repeat
: flag[i]:=ture;
: while turn < > i
: do begin
: while flag[j] do no-op;
: turn:=i;
: end
: //critical section
: flag[i]:=false;
: //remainder section
: until fasle;
: 類似像這樣給code然後要求證明
: mutual exclusive、progress、bounded waiting
ME 有 因為有turn的存在 導致進入CS唯一
progress 無 若turn=j 則Pi要進CS要等Pj進去後才能進
BW 無 原因同上 Pj若不進去的話 就無窮等待啦
--
相簿內有一批資工用書 好便宜的阿...
http://www.wretch.cc/album/chris750630
有需要就給個留言吧...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.129.226
→ chris750630:不要理這篇 我解錯了解錯了解錯了 XDDDDDD 08/21 15:29
→ nypgand1:哈哈 這本來就很難嘛 大家一起討論囉 08/21 15:29