function V(semaphore S):
Atomically increment S
[S ← S + 1]
function P(semaphore S):
repeat:
Between repetitions of the loop other processes may operate on the semaphore
[if S > 0:
Atomically decrement S - note that S cannot become negative
S ← S - 1
break]
沒有留言:
張貼留言