-->
当前位置:首页 > 题库 > 正文内容

填空题:(11空)在测量控制系统中的数据采集任务,把所采集的数据送至一单缓冲区;计算任务从该单缓冲中取出数据进行计算。试写出利用信号量机制实现两者

Luz3年前 (2022-11-16)题库734
在测量控制系统中的数据采集任务,把所采集的数据送至一单缓冲区;计算任务从该单缓冲中取出数据进行计算。试写出利用信号量机制实现两者共享单缓冲的同步算法。(方法1)(使用wait、signal)

Var mutex, empty, full: semaphore:=, , ;
gather:
begin
repeat
……
gather data in nextp;
(empty);
(mutex);
buffer:=nextp;
(mutex);
(full);
until false;
end
compute:
begin
repeat
……
(full);
(mutex);
nextc:=buffer;
(mutex);
(empty);
compute data in nextc;
until false;
end






答案:
第1空:1 ||

第2空:1 ||

第3空:0 ||

第4空:wait ||

第5空:wait ||

第6空:signal ||

第7空:signal ||

第8空:wait ||

第9空:wait ||

第10空:signal ||

第11空:signal ||

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。