当前位置:网站首页>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 ~
边栏推荐
- [section 6 functions]
- Jerry's ble dynamic power regulation [chapter]
- MapReduce之分区案例的代码实现
- 广和通携手中国移动、惠普、联发科、英特尔合作打造5G全互联PC泛终端系列产品
- Missing setjarbyclass() when running MapReduce task. No class found
- RK3308--固件编译
- Detailed explanation of RGB color space, hue, saturation, brightness and HSV color space
- Cube 技术解读 | Cube 渲染设计的前世今生
- Middle office: Data middle office, business middle office, technology middle office, application middle office, AI middle office
- Recommend an easy-to-use designer navigation website
猜你喜欢

排序与分页

无线通信模组如何助力智能无人机打造“空中物联网”?

姿态估计之2D人体姿态估计 - SimDR: Is 2D Heatmap Representation Even Necessary for Human Pose Estimation?

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

姿态估计之2D人体姿态估计 - (OpenPose) Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields
![leetcode:730. Statistics of different palindrome subsequences [traversed by point and surface interval DP + 3D DP + diagonal]](/img/90/79c51f944709ef230f394e874aa9ac.png)
leetcode:730. Statistics of different palindrome subsequences [traversed by point and surface interval DP + 3D DP + diagonal]

Apache atlas quick start

Live broadcast preview | deconstruct OLAP! The new multidimensional analysis architecture paradigm is fully open! Apache Doris will bring five big issues!
Cap version 6.1 Release Notice

Recommend an easy-to-use designer navigation website
随机推荐
Join operation cases in the reduce phase of MapReduce
Query-Convert QuickView是灰掉的解决办法(转)_SAP刘梦
Add Anaconda's bin directory to path
无线通信模组如何助力智能无人机打造“空中物联网”?
姿态估计之2D人体姿态估计 - Human Pose Regression with Residual Log-likelihood Estimation(RLE)[仅链接]
Driver development and abnormal analysis of "technical dry goods" industrial touch screen (serial)
MapReduce之排序及序列化案例的代码实现
从“初代播种”到“落地生花”,广和通在5G商用三年间做了什么?
[untitled]
Middle office: Data middle office, business middle office, technology middle office, application middle office, AI middle office
sm59远程连接,如果提示没有host,则在服务器上加上host,然后重启sap_SAP刘梦
姿态估计之2D人体姿态估计 - Associative Embedding: End-to-End Learning for Joint Detection and Grouping
Jerry's ble OTA upgrade requires shutting down unnecessary peripherals [chapter]
Application scenario introduction of nixie tube driver chip + voice chip, wt588e02b-24ss
这几个垂直类小众导航网站,你绝对不会想错过
软件测试架构师,给后辈的16条忠告,快看看别错过
2D human pose estimation for pose estimation - simdr: is 2D Heatmap representation even necessity for human pose estimation?
Detailed installation steps of mysql8
Scope and closure
Common sense: the number of neurons in the brain of mice is about 70million and that of humans is about 86billion