当前位置:网站首页>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 ~
边栏推荐
- [untitled]
- Comply with medical reform and actively layout -- insight into the development of high-value medical consumables under the background of centralized purchase 2022
- Detailed installation steps of mysql8
- 2D human posture estimation for posture estimation - simple baseline (SBL)
- 2290. Minimum Obstacle Removal to Reach Corner
- 2D human pose estimation with residual log likelihood estimation (RLE) [link only]
- MapReduce案例之排序
- LocalDate与Date相互转换
- Missing setjarbyclass() when running MapReduce task. No class found
- Necessary tools for automatic operation and maintenance shell script introduction
猜你喜欢

Use of hardware instruments

推荐一个好用的设计师导航网址

服务器运维环境安全体系(下篇)

Driver development and abnormal analysis of "technical dry goods" industrial touch screen (serial)

Solution to some problems of shadow knife RPA learning and meeting Excel

Rk3308 key and LED light

姿态估计之2D人体姿态估计 - Distribution Aware Coordinate Representation for Human Pose Estimation【转-修改】

Smart home (3) competitive product analysis of Intelligent Interaction

探索数据可视化开发平台FlyFish开源背后的秘密!
![2D human pose estimation with residual log likelihood estimation (RLE) [link only]](/img/c7/9c25da07236ef0bd241b6023e82306.gif)
2D human pose estimation with residual log likelihood estimation (RLE) [link only]
随机推荐
这几个垂直类小众导航网站,你绝对不会想错过
Jerry's ble PB2 cannot be hardware grounded or connected to triode base [chapter]
MapReduce之排序及序列化案例的代码实现
You will never want to miss these vertical niche navigation websites
2D human pose estimation with residual log likelihood estimation (RLE) [link only]
torch. nn. utils. rnn. pad_ Detailed explanation of sequence() [pytoch getting started manual]
Save a window with a specific size, resolution, or background color
C # game prototype character map dual movement
Use of hardware instruments
sm59远程连接,如果提示没有host,则在服务器上加上host,然后重启sap_SAP刘梦
kubernetes 二进制安装(v1.20.16)(五)验证 master 部署
Query-Convert QuickView是灰掉的解决办法(转)_SAP刘梦
Opencv 4 handwriting recognition: perfect self built training set
【第六节 函数】
Google X开源抓取机械臂,无需人工标注就能一眼找到目标零件[转]
Kubernetes binary installation (v1.20.16) (V) verifying master deployment
2D human pose estimation for pose estimation - simdr: is 2D Heatmap representation even necessity for human pose estimation?
The fragrant locust flowers on the fragrant locust road have been in a hurry for four years.
Jerry's ble timer clock source cannot choose OSC crystal oscillator [chapter]
"Bloom Cup" 5g Application Award grand slam! Several joint projects of guanghetong won the first, second and third prizes in the general product theme competition