// synch.ii /** * A semaphore is a synchronization object. It * has the standard atomic wait (P) and signal (V) * operations. */ interface Semaphore { /** * Wait on the semaphore. */ wait() /** * Signal the semaphore. */ signal() } /** * Creates a counting semaphore. It can count from * 0 to max, and begins at init. The wait operation * causes the calling thread to block until the count is > 0, * then decrements the count and unblocks the thread. * The signal operation causes the count to increment up to * a maximum of max. * A standard binary semaphore can be created by passing * 1 for max. * Precondition: max > 0, 0 <= init <= max * Postcondition: A semaphore, as just described, is returned. * null is returned if no more semaphores can be allocated. */ createSemaphore(init:int, max:int):Semaphore