Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the original meaning of P and V operations in a context of a semaphore?

Does anybody know why semaphore operations are called P and V? Every time I read a chapter on semaphores it says something like the following:

In order for the thread to obtain a resource it executes a P operation. And in order for the thread to release a resource it executes a V operation.

What does P and V stand for? Why they are not called wait and signal?

like image 486
flashburn Avatar asked Apr 13 '15 13:04

flashburn


People also ask

What does P and V mean semaphore?

P semaphore function signals that the task requires a resource and if not available waits for it. ● V semaphore function signals which the task passes to the OS that the resource is now free for the other users.

What is P and V in operating system?

A simple way to understand wait (P) and signal (V) operations is: wait: Decrements the value of semaphore variable by 1. If the new value of the semaphore variable is negative, the process executing wait is blocked (i.e., added to the semaphore's queue).

Why P and V operations of a semaphore should be atomic?

They are required to be to ensure that one thread cannot obtain resources while another thread does. If it wasn't, this would imply that two threads could begin accessing a resource and then be switched out of the CPU and another process could gain access to it instead.

What are the two basic operations of semaphore?

Semaphores are integer variables that are used to solve the critical section problem by using two atomic operations, wait and signal that are used for process synchronization. The wait operation decrements the value of its argument S, if it is positive.


2 Answers

Dijkstra, one of the inventors of semaphores, used P and V. The letters come from the Dutch words Probeer (try) and Verhoog (increment).

See also: https://cs.nyu.edu/~yap/classes/os/resources/origin_of_PV.html

like image 173
Kris Avatar answered Oct 29 '22 23:10

Kris


@Kris answer is just partially right.

V stands for 'Verhoog' and P stands for 'Prolaag', not 'Probeer' as cited here.

Verhoog can be translated as 'increasing'. Decreasing would be 'Verlaag', but for better distinction between the letters Dijkstra invented the word 'Prolaag'.

See the naming in the original paper.

like image 29
Lars Quentin Avatar answered Oct 30 '22 00:10

Lars Quentin