电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

二十 九阴真经之北航篇——生产者-消费者扩展


发布日期:2018/7/30
 

生产者消费者扩展

有n+个进程AA···An和B

()AA···An通过同一个缓沖池各自不断地向B发送消息B不断地取消息它必须取走发来的每个消息刚开始时缓沖区为空使用Pv操作实现之

()若缓沖区个数增至M个试用PV实现正确通讯

这个问题较为简单请读者自行解决这里给出参考答案

The PV code Using Pascal

var fullemptymutex:semaphore;

full=;

empty=;

mutex=;

cobegin

procedure A_i(i=n) procedure B:

begin begin

p(empty); P(full);

p(mutex); p(mutex);

put message to the buffer; Get the message;

v(mutex); v(mutex);

v(full); v(empty);

end end

返回《操作系统之PV金典》

上一篇:浙江省2013年7月高等教育自学考试操作系统概论试题[1]

下一篇:浙江省2013年4月自学考试 操作系统试题[1]