在测温系统中要完成采样、转换和显示等任务。采样过程把从传感器上得到的整型微电压值存入一个缓冲区,转换过程把微电压值从缓冲区中取出

作者:高老师 浏览 1

在测温系统中要完成采样、转换和显示等任务。采样过程把从传感器上得到的整型微电压值存入一个缓冲区,转换过程把微电压值从缓冲区中取出,计算转换成温度值再存入该缓冲区,显示过程把缓冲区中的温度值取出并显示。试用PV操作实现三个过程共享缓冲区的同步问题。
【正确答案】:begin Buffer:integer; SS,SC,SD:semaphore; SS:=1; SC:=0; SD:=0; cobegin procesS Sample begin L1:get a sample; P(SS); Buffer:=sample; V(SC); goto L1; end; process Convert begin L2:P(SC); take a sample from Buffer; convert the sample to temperature; Buffer:=temperat ure; V(SD); goto L2; end; Process DisplaY begin L3:P(SD); take a temperature from Buffer; V(SS); display the temperature; goto L3; end; coend; end;

📱 扫码体验刷题小程序

微信小程序二维码

扫一扫使用我们的微信小程序

热门题目

已复制到剪贴板