www.pudn.com > 哲学家问题0.rar > phi.cpp
int NUM=5; //哲学家数量
binarysem chops[5]; //筷子的记录型信号量,及其数量(要与NUM相同)
binarysem count; //辅助打印不被断开
int incid(int id) //加1后取模
{int a;
if (id==NUM-1) a=0; else a=(id+1);
return a;
}
void pickup(int id)
{
int id1,id2;
cout<<"The "<