p2进程管理课程.pptVIP

  • 7
  • 0
  • 约1.7万字
  • 约 94页
  • 2016-12-04 发布于江苏
  • 举报
2.5管程机制 引入原因: 为了避免凡要使用临界资源的进程都自备同步操作wait(s)和signal(s).将同步操作的机制和临界资源结合到一起,形成管程。 2.5.1管程的基本概念 一、定义:一个数据结构和能为并发进程所执行的一组操作。 局部于管程的共享变量。 对该数据结构进程操作的一组过程。 对局部管程数据设置初值。 二、条件变量: x.y: x.wait; x.signal; x.queue 2.5.2利用管程解决生产者——消费者问题 一、建立管程:PC 包括:二过程: (1)put(item)过程; (2)get(item)过程 一变量:count≥n时满;≤0 时空 初始: in=out=count=0 Type producer-consumer=monitor var in,out,count:integer; buffer: array [0,…,n-1] of item; notfull, notempty: condition; procedure entry put (item) procedure entry get (item) 2.5.2利用管程解决生产者——消费者问题 Procedure entry put(item) begin if count ≥n then notfull.wait; buffer(in

文档评论(0)

1亿VIP精品文档

相关文档