当前位置:网站首页>PV operation daily question - Restaurant Service
PV operation daily question - Restaurant Service
2022-06-10 16:10:00 【liangsena】
Restaurant service problem
It is similar to the problem of single log bridge , Later, there is the problem of single wooden bridge
One 、 Problem description
A restaurant serves Chinese food 、 Thai food and Spanish food , Customers can choose which kind of food to eat . The restaurant has the following regulations : The restaurant only offers one kind of cuisine at any one time , And it shall be provided according to the requirements of the first customer entering the restaurant , The last customer who chooses a certain dish can only provide another dish after leaving ; Customers who choose the current cuisine can enter the restaurant immediately , The restaurant allows multiple customers to eat at the same time , There is no limit to the quantity ; When other customers have to wait for their dishes to be offered , Then you can enter the restaurant for dinner in turn .
Please use PV The operation describes the above synchronization and mutual exclusion problems , The meaning of semaphore and initial value is given .
Two 、 problem solving
// Set three values :1: Chinese food ,2: Thailand cuisine ,3: Spanish food
int i=1,2,3;
int count_i=0; // The current number of people in a restaurant
semaphore mutex=1; // Restaurants offer mutually exclusive cuisines
semaphore mutex_i=1;// Exclusive access count Variable
Costumers_i()
{
P(mutex_i);
count-i++;
if(count_i==1)
{
P(mutex);
}
V(mutex_i);
having dinner ;
P(mutex_i);
count_i--;
if(count_i==0)
{
V(mutex);
}
V(mutex);
}
The original answer is very long , Make a list of each one , Feel no need to , Just use variables instead of .
3、 ... and 、 twitter
Today was too tired , That's it ~
边栏推荐
- Application scenario introduction of nixie tube driver chip + voice chip, wt588e02b-24ss
- Apple mailbox configures QQ mailbox, 163 mailbox, edu mailbox, Gmail mailbox, and obtains Gmail calendar
- [untitled] audio Bluetooth voice chip, wt2605c-32n real-time recording upload technical scheme introduction
- 直播預告 | 解構OLAP!新型多維分析架構範式全公開!Apache Doris 將帶來五個重磅議題!
- 姿态估计之2D人体姿态估计 - Distribution Aware Coordinate Representation for Human Pose Estimation【转-修改】
- 【无标题】
- 广和通高算力智能模组为万亿级市场5G C-V2X注智
- Join operation cases in the reduce phase of MapReduce
- Middle office: Data middle office, business middle office, technology middle office, application middle office, AI middle office
- 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!
猜你喜欢

这几个垂直类小众导航网站,你绝对不会想错过

"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

Fortex Fangda releases the electronic trading ecosystem to share and win-win with customers

Application scenario introduction of nixie tube driver chip + voice chip, wt588e02b-24ss

Explore the secrets behind the open source data visualization development platform flyfish!

Middle office: Data middle office, business middle office, technology middle office, application middle office, AI middle office

MapReduce之排序及序列化案例的代码实现

顺应医改,积极布局——集采背景下的高值医用耗材发展洞察2022

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!

Implementation of word count case code in MapReduce
随机推荐
探索数据可视化开发平台FlyFish开源背后的秘密!
Error org codehaus. plexus. component. repository. exception. ComponentLookupException:
Unified certification center oauth2 certification pit
Sword finger offer 06 Print linked list from end to end
Conversion between localdate and date
ORB_ Slam2 visual inertial tight coupling positioning technology route and code explanation 1 - IMU flow pattern pre integration
Scope and closure
AttributeError: module ‘gym. envs. Box2d 'has no attribute' lunarlander 'solution
【历史上的今天】6 月 10 日:Apple II 问世;微软收购 GECAD;发明“软件工程”一词的科技先驱出生
Smart home (3) competitive product analysis of Intelligent Interaction
This and object prototypes
json.load(s)与json.dump(s)
Jerry's interface for obtaining ble broadcast package and profile data [chapter]
uniapp中常用到的方法(部分) - 時間戳問題及富文本解析圖片問題
Recommend an easy-to-use designer navigation website
【无标题】
Solution to some problems of shadow knife RPA learning and meeting Excel
[section 14 STL container II]
What are the top ten futures companies with low handling fees? Is it safe?
点击解锁广和通5G模组“关键词”