※ 引述《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);
: