当前位置:网站首页>PV operation daily question - black and white chess question (variant)
PV operation daily question - black and white chess question (variant)
2022-06-10 16:10:00 【liangsena】
Black and white chess problem ( Variant )
One 、 Problem description
There is a box with an equal number of black and white chessmen various 100 gold , Now use the automatic sorting system to separate the black and white pieces , There are two processes in the system P1 and P2.P1 Responsible for sorting white chess pieces ,P2 Is responsible for sorting the black chess pieces , The two must be sorted alternately , Press Black first white then In sequence , And it shall not be stopped before the end of sorting . use PV Operation solves the problem .
Two 、 problem solving
semaphore flag1=1;
semaphore flag2=0;
int blackNum=100;
int whiteNum=100;
P2()
{
while(1)
{
P(flag2);
P(blackNum);
Sort a black piece ;
V(flag1); // Signal to P1
}
}
P1()
{
while(1)
{
P(flag1);
P(whiteNum);
Sort a white piece ;
V(flag2); // Signal to P2
}
}
3、 ... and 、 twitter
Not much. , Only the execution order and the number of pieces are given , Slip away ~
边栏推荐
- Opencv 4 handwriting recognition: perfect self built training set
- Rk3308 key and LED light
- [section 7 function]
- 影刀RPA学习和遇见excel部分问题解决方式
- 2290. Minimum Obstacle Removal to Reach Corner
- 广和通高算力智能模组为万亿级市场5G C-V2X注智
- NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
- Click to unlock "keyword" of guanghetong 5g module
- RK3308--固件编译
- Apache atlas quick start
猜你喜欢

广和通高算力智能模组为万亿级市场5G C-V2X注智

运行mapreduce任务缺失setJarByClass()报错找不到类
![[untitled] audio Bluetooth voice chip, wt2605c-32n real-time recording upload technical scheme introduction](/img/13/9674d685dfa0b62d1d1fa5362a4c7e.png)
[untitled] audio Bluetooth voice chip, wt2605c-32n real-time recording upload technical scheme introduction

硬件仪器的使用

安霸CV2FS/CV22FS获得ASIL C芯片功能安全认证,超越市场同类芯片水平

MySQL8安装详细步骤

Smart home (3) competitive product analysis of Intelligent Interaction

MapReduce之Reduce阶段的join操作案例

Methods commonly used in uniapp (part) - timestamp problem and rich text parsing image problem

姿态估计之2D人体姿态估计 - SimDR: Is 2D Heatmap Representation Even Necessary for Human Pose Estimation?
随机推荐
sm59远程连接,如果提示没有host,则在服务器上加上host,然后重启sap_SAP刘梦
What are the top ten futures companies with low handling fees? Is it safe?
torch. nn. utils. rnn. pad_ Detailed explanation of sequence() [pytoch getting started manual]
Comply with medical reform and actively layout -- insight into the development of high-value medical consumables under the background of centralized purchase 2022
【历史上的今天】6 月 10 日:Apple II 问世;微软收购 GECAD;发明“软件工程”一词的科技先驱出生
[MySQL basics]
Live broadcast preview | deconstruct OLAP! The new multidimensional analysis architecture paradigm is fully open! Apache Doris will bring five big issues!
RK3308--8声道改成双声道+录音增益
MapReduce案例之多Map阶段求共同好友
影刀RPA学习和遇见excel部分问题解决方式
2D human posture estimation for posture estimation - simple baseline (SBL)
Query-Convert QuickView是灰掉的解决办法(转)_SAP刘梦
NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
json. Load (s) and json dump(s)
2290. Minimum Obstacle Removal to Reach Corner
Méthodes couramment utilisées dans uniapp - TIMESTAMP et Rich Text Analysis picture
MapReduce案例之排序
【无标题】
Jerry's ble timer clock source cannot choose OSC crystal oscillator [chapter]
leetcode:730. 统计不同回文子序列【由点及面区间dp + 三维dp + 对角线遍历】