Wait Operation

If the semaphore value is 1 or greater, the semaphore value decrements by one and the API call returns immediately. If the semaphore value is 0, then the task is blocked until the value increases, at which point the value decrements by one and the waiting task resumes. If there are multiple tasks waiting for a semaphore, they are ordered by task priority, so a high priority task will unblock before a lower priority task.