What is PV operation?(TOP 1)

What is PV operation? Just eat ice cream in summer.

As for the semaphore, it can be considered as a refrigerator, and then we should understand the two things of capacity and the current number of ice cream bars. The P operation is equivalent to getting tired from the refrigerator just after playing the ball. If you do n’t wait forever, then until the V operation, your dad bought the ice cream and put it in the refrigerator. In order to avoid the P operation, you will have to wait for a while After you use it, you will also be stuck in a blocked waiting state, because you ca n’t always eat it. You also have other friends and brothers and sisters, which are equivalent to other processes. Your dad ’s V operation is to send ice cream to the refrigerator. If the refrigerator is full, wait until there is a P operation. Remove the ice cream from the refrigerator. P operation: subtract 1 from the ice cream. After the reduction, the ice cream is greater than or equal to 0. , Indicating that ice cream has been obtained, the thread continues. Otherwise, the thread is blocked. Operation V: Add 1 to the number of ice cream bars. After the addition, the number of ice cream bars is less than or equal to the capacity, indicating that your dad has successfully purchased ice cream bars and the thread continues. Otherwise, the thread is blocked.

发布了13 篇原创文章 · 获赞 2 · 访问量 1046

猜你喜欢

转载自blog.csdn.net/weixin_44033021/article/details/104045011
Pv