As time has passed, other names for these methods have included ???wait,??? ???down,??? and ???sleep???
for P, and ???signal,??? ???up,??? and ???wake??? for V. Multiple names for the same operations can make it difficult to read
different accounts of semaphores, but the idea is simple.
When a process or thread invokes the P operation, the semaphore P method decrements the integer, and if
the value is now less than 0, the operating system blocks the process. Later, some other process will invoke the
V operation using the same semaphore. The V operation will increment the value of the integer, and if the integer
value is now equal to or greater than zero, the process that was blocked will be unblocked.
The semaphore construct is very flexible. Its integer value can be initialized to allow for a variety of uses.
Most often it is initialized to 1, which allows the first process access via the P operation, and blocks any other
process until the first process completes its critical section and executes the V operation.
A semaphore also may be initialized to 0, which will cause the first process that executes a P operation to
block. Some other process will have to execute a V operation on the same semaphore before the first process
will be unblocked.
Pages:
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291