Our lives have a lot of things happening every day, most of the things we can deal with, some things we have to work with others, such as going to restaurants, restaurants are one of our frequented place, but we often encounter this situation, the only restaurant nearby, I am very hungry, do not want to go to other restaurants, Just when I came out of the position, the waiter let me wait, see others in there eating a mouthful of oil, hate ah ...
Just the scene, very life, we may as well let the time pause in the above sentence moment, we see this can explain PV operation, first we define, the restaurant has 3 tables, restaurant operation is only a chef, the guests are uncertain, on the chef's case on the side to do a few dishes, Guests are ordered to take care of the guests (small tickets), the chef read the number, tell him what to do.
We are so defined that the chef cook a few dishes is the chef's signal for SC, guests see the restaurant left a few seats is the guest's signal sp.
9 o'clock in the morning, there is not a guest in the restaurant, there is a guest come, have not ordered
Sc=0
Sp=3
The guest ordered a dish
Sc=1
sp=2
11 o'clock in the morning, the guests are full, no one waiting, all the guests ordered
Sc=3
Sp=0
11:30, the guest is full, there are three guests waiting, the guests ordered not yet.
Sc=3
Sp=-3
This time we'll explain the pv,p operation is to see if there are resources, for the chef is to see if there is no one to cook, for the customer is to see how many positions; v operation is, have a customer finished dinner, released a position, for the chef to judge to do not cook, someone waiting, to do, no one waiting, wait.
The chef of the program is set to
Sc=0
Sp=3
The chef's code is
P (Sc): see if you want to cook.
Cooking + Food Delivery
V (Sp): informing customers to eat
Customer's Code:
P (Sp): see if I can eat.
Order + Finish Eating
V (Sc): Inform the chef to have an empty position
Here we understand the significance of PV operation, Restaurant makes one of our public resources, we have to make good use of it, we have to queue, customers line up to order, the chef lined up to cook, so we will be harmonious, if only a table chef to do the customer can eat, is the relationship between cooperation, also called synchronization, if the restaurant left a position, Two customers came, he two dozen up, this is called mutual exclusion. So PV operation is to solve the problem of public resource utilization, which is the problem of critical area. I hope you can understand a little bit.