__进程同步与通信(第三版).pptVIP

  • 2
  • 0
  • 约2.41万字
  • 约 91页
  • 2019-11-09 发布于湖北
  • 举报
注意 P(mutex)、V(mutex)在同一程序成对出现。而且放于访问临界资源代码前后。 如:p(mutex) reader:=reader+1 V(mutex) 一般信号量P操作、V操作也成对出现,但出现在不同的 进程中。 信号量必须初始化,且其初值不同,其实现过程也有差别。 出现连续两个P操作,先后顺序要注意。 管程解决哲学家进餐问题 Type dining-philosophers=monitor var state:array[0…4] of (thinking,hungry,eating); var self:array[0…4] of condition; Procedure entry pickup(i:0…4) begin state[i]:=hungry; test(i); if state[i] ≠eating then self[i].wait end; Procedure entry putdown(i:0…4) begin state[i]:=thinking; test(i+4 mod 5); test(i+1 mod 5); end; Procedure test(k:0…4) begi

文档评论(0)

1亿VIP精品文档

相关文档