※ 引述《tzutengweng (神奇的湯姆)》之銘言:
我先附題目
Consider a process synchrinization problem , in which we have 5 people
competing for 4 chairs , and each chair can be used by one person at a time
Let the competing go by rounds. That is , 5 people compete for 4 chairs in the
begining of each round , and the 4 winners release their chairs at the end of
each round so that the next round starts .
Please use semaphores to write programs for the entry and exit section of
the 5 people so that every person will win at least ine time in competing
the chairs for every 3 consecutive rounds.
: : 【OS】
: : 8.好像表達的沒有很好 想參考一下大家怎麼寫的QQ
: : Chair: semaphone=4;
: : Pi: int=0;
: : while(前兩輪)
: : {
: : Pi++;
: : wait(chair);
: : C.S.
: : signal(chair);
: : }
: : if(Pi==0)then wait(chair);
: : wait(chair);
: : C.S.
: : signal(chair);
: