Acquire one unit of resource from the semaphore.If no resource is available,acquire will block and wait until any resource is available.If there are multiple tasks both waiting for the same resource,new resource will be delivered in a first-come-first-serve manner.
acquire itself never fail, and will wait indefinitely.However, since acquire is a blocking point,the task running acquire may be cancelled,in this case, an cancellation will be raised from acquire.
Release a unit of resource back to the semaphore. This function never blocks.If there are waiters currently blocked on the semaphore,the first waiter will be woken to acquire the resource.
release must be called after a successful acquire,in strictly one-to-one manner.If the value of the semaphore exceed its size,release will abort immediately.
Try to acquire one unit of resource from the semaphore.If resource is successfully acquired, true is returned,Otherwise, false is returned immediately without blocking.