ABSTRACT

When a semaphore is first created, the kernel assigns to it an associated semaphore con­ trol block (SCB), a unique ID, a value (binary or a count), and a task-waiting list, as shown in Figure 6.1.

A semaphore is like a key that allows a task to carry out some operation or to access a resource. If the task can acquire the semaphore, it can carry out the intended opera­ tion or access the resource. A single semaphore can be acquired a finite number of times. In this sense, acquiring a semaphore is like acquiring the duplicate of a key from an apartment manager-when the apartment manager runs out of duplicates, the manager can give out no more keys. Like­ wise, when a semaphore’s limit is reached, it can no longer be acquired until someone gives a key back or releases the semaphore.