当前位置:网站首页>PV operation daily question - black and white chess question
PV operation daily question - black and white chess question
2022-06-10 16:10:00 【liangsena】
Black and white chessmen problem chessmen
reminder , The code for this topic may be very simple , But a little around , Similar to the problem of orange and apple in the front, add the fruit alternately . All right. , Start !
One 、 Problem description
There is a box with an equal number of black and white chessmen , Now use the automatic sorting system to separate the black and white pieces , There are Two processes 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 , And it shall not be stopped before the end of sorting . use PV Operation solves the problem .
Two 、 problem solving
: So to understand , hold P1 and P2 As two resources , Mutually exclusive access , Contrary to the orange apple problem .
semaphore flag1=1;
semaphore flag2=0;
P1()
{
while(1)
{
P(flag1);
Sort a white piece ;
V(flag2); // Signal to P2
}
}
P2()
{
while(1)
{
P(flag2);
Sort a black piece ;
V(flag1); // Signal to P1
}
}
3、 ... and 、 twitter
After understanding , After reading the code, do you think the title is super simple ~
边栏推荐
- Two methods of modifying PIP download source
- Error org codehaus. plexus. component. repository. exception. ComponentLookupException:
- What are the top ten futures companies with low handling fees? Is it safe?
- Join operation cases in the map phase of MapReduce
- 硬件仪器的使用
- How the terminator sets the font to display different colors
- [MySQL basics]
- NanoMQ Newsletter 2022-05|v0.8.0 发布,新增 WebHook 拓展接口和连接认证 API
- 【第14节 STL容器二】
- Query convert quickview is a grayed out solution (turn)_ SAP LIUMENG
猜你喜欢

2290. Minimum Obstacle Removal to Reach Corner

RK3308--固件编译

姿态估计之2D人体姿态估计 - Numerical Coordinate Regression with Convolutional Neural Networks(DSNT)

Aggregate sum of MapReduce cases
![Jerry's ble timer clock source cannot choose OSC crystal oscillator [chapter]](/img/87/9e78938faa327487e8d7045ab94bf2.png)
Jerry's ble timer clock source cannot choose OSC crystal oscillator [chapter]

2290. Minimum Obstacle Removal to Reach Corner

Distribution aware coordinate representation for human pose estimation

姿态估计之2D人体姿态估计 - Associative Embedding: End-to-End Learning for Joint Detection and Grouping

MySQL8安装详细步骤

MapReduce案例之多Map阶段求共同好友
随机推荐
Query-Convert QuickView是灰掉的解决办法(转)_SAP刘梦
torch. utils. data. Dataloader() details [pytoch getting started manual]
Jerry's ble OTA upgrade requires shutting down unnecessary peripherals [chapter]
Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]
ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 1 - IMU flow pattern pre integration
kubernetes 二进制安装(v1.20.16)(五)验证 master 部署
[untitled]
Aperçu en direct | déconstruire OLAP! Le nouveau paradigme de l'architecture d'analyse multidimensionnelle est entièrement ouvert! Apache Doris va apporter cinq gros problèmes!
Application scenario introduction of nixie tube driver chip + voice chip, wt588e02b-24ss
排序与分页
“绽放杯”5G应用奖项大满贯!广和通多个联合项目荣获通用产品专题赛一、二、三等奖
智能家居(3)智能交互的竞品分析
RK3308--8声道改成双声道+录音增益
Join operation cases in the reduce phase of MapReduce
Code implementation of sorting and serializing cases in MapReduce
Aggregate sum of MapReduce cases
[object].
影刀RPA学习和遇见excel部分问题解决方式
Online document collaboration tool is the first step to improve work efficiency
运行mapreduce任务缺失setJarByClass()报错找不到类