2019哲学家用餐
作者:互联网
sem bowl; sem chopsticks[n]; for(int i=0;i<n;i++) chopsticks[i].value=1; bowl.value=min(n-1,m)//bowl.value<=n-1,确保不死锁 while(True) { p(bowl); p(chopsticks[i]); p(chopsticks[(i+1]MOD n); 就餐; v(chopsticks[i]); v(chopsticks[(i+1]MOD n); v(bowl); }
标签:哲学家,int,用餐,bowl,2019,chopsticks,sem 来源: https://www.cnblogs.com/yangmenda/p/11708061.html