- 7
- 0
- 约5.86万字
- 约 66页
- 2020-03-15 发布于安徽
- 举报
CH3 应用题参考答案
有三个并发进程:R负责从输入设备读入信息块,M负责对信息块加工处理;P负责打印输出信息块。今提供;
一个缓冲区,可放置K个信息块;
二个缓冲区,每个可放置K个信息块;
试用信号量和P、V操作写出三个进程正确工作的流程。
答:
var B : array[0,k-1] of item ;
sread : semaphore := k ;
smanage : semaphore := 0 ;
swrite : semaphore := 0;
rptr : integer := 0 ;
mptr : integer := 0 ;
wptr : integer := 0 ;
x : item
cobegin
process reader ;
begin
L1: read a message into x ;
P(sread) ;
B[rptr]:= x ;
rptr := ( rptr+1) mod k;
V(smanage) ;
goto L1 ;
end ;
process manager;
begin
L2: P(smanage) ;
x := B[mptr] ;
mptr :=(mptr+1) mod k;
manage the message in x ;
B[mptr] := x;
V(swrite) ;
goto L
您可能关注的文档
最近下载
- 昆虫信息素项目可行性研究报告.docx
- 2026年中考语文考前抢分速记手册(上海专版).docx VIP
- 中国台球协会技能等级考试中式台球考题说明.pdf VIP
- TSGD00012009压力管道安全技术监察规程工业管道管规.pdf
- 物业客户投诉分析报告.pptx VIP
- 2025中小学教师高级职称专业水平能力试题库(含答案).pptx VIP
- 2026年全款房屋买卖合同_全款房屋买卖合同范本.docx VIP
- 新解读《GB_T 32305-2015航天产品保证》最新解读.docx VIP
- 四年级体育下册前滚翻教案.doc VIP
- 2025年中小学教师高级职称专业水平能力题库及参考答案 .pptx VIP
原创力文档

文档评论(0)