1.问题:假设某系统有四个进程。input1和input2进程负责从不同设备读取数据,分别表示为data1和data2,存放在缓冲区Buffer中,output1和output2进程负责从Buffer中分别获取data1和data2。Buffer中每次只能存放一个数据。
var empty,full1,full2:semaphore;
empty.value = 1;①_______;②_______
input1:
Begin
③_______
放数据data1
④_______
End
----------------------------------
input2:
Begin
⑤_______
放数据data2;
⑥_______
End
---------------------------------
output1:
Begin
⑦_______
取数据data1;
⑧_______
End
-----------------------------------
output2:
Begin
⑨_______
取数据data2;
⑩_______
End
----------------------------------------
按要求是个进程协调完成任务,补充完整下列程序,将编号①~⑩处空缺的内容填写
2.答案:
①full1.value=0;
②full2.value=0;
③wait(empty);
④signal(full1);
⑤wait(empty);
⑥signal(full2);
⑦wait(full1);
⑧signal(empty);
⑨wait(full2);
⑩signal(empty);
标签:full1,full2,End,补充,综合题,Buffer,_______,empty From: https://www.cnblogs.com/saoge/p/18089510