1Chapter 7 of
The file is intended for on-screen viewing free of charge; use of this
material in any other format is subject to a fee. The file is provided for
individual non-commercial use only. On-line edition copyright (c) 1996 by
Addison-Wesley Publishing Company. Permission is granted to print or
photocopy (this document) for a fee of $0.02 per page, per copy, payable to
Addison-Wesley Longman Publishing. All other rights reserved.
s consists of an integer value
v and a queue q. There are two atomic operations
on a binary semaphore.
P(s): if v = 1
v = 0
else
add this process to q
block this process
V(s): if q is empty
v = 1
else
remove a process from q
unblock the removed process