Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What are the p operations and v operations in threads?
What are the p operations and v operations in threads?

Let’s talk about the semaphore mechanism first. The semaphore mechanism is a process synchronization tool proposed to realize the concurrent execution of processes in a multi-program environment!

The Dutch scholar Dijkstra originally defined the integer semaphore as an integer S used to represent the number of resources. It is different from the general integer. In addition to initialization, it can only pass two standard Atomic operations wait(S) and signal(S) are used to access. For a long time, these two operations have been called P and v operations.

The description is:

wait(S):while S<=0 do noop;

S:S-1;

signal(S):S: S+1;