哲学家与进程调度.docxVIP

  • 4
  • 0
  • 约4.56千字
  • 约 8页
  • 2019-03-03 发布于湖南
  • 举报
#include stdio.h struct{ char pstatus; //哲学家状态 int pid;//哲学家编号 int waiter1; int priority;//优先级,数值大的就餐的优先级高 }pcb[6]; struct sp{ int stick; //筷子状态,0表示可使用或表示空闲,1表示有人在使用或不空闲 }num[6];//筷子编号 struct{ int value; //互斥信号量,临界区数,初值为1 int waiter2; //同步信号量,初值为0 }sem[3]; char stack[11][6]; int m1,m2;//为系统设置的公用数据被三个进程共享使用。 int i,ep; //ep表示正在就餐的哲学家的pid,i为通用寄存器 char addr; //addr为程序计数器 void init(); int find(); int hungry(); int process1(); int process2(); int process3(); int process4(); int process5(); int p(int,int ,char); int v(int,int ,char); int main(){ init(); printf

文档评论(0)

1亿VIP精品文档

相关文档