## semaphore_wait

Function - Wait on the specified semaphore.

### SYNOPSIS

    kern_return_t   semaphore_wait
                    (semaphore_t                          semaphore);

### PARAMETERS

semaphore
  [in send right] The port naming the semaphore that the wait operation is being performed upon.

### DESCRIPTION

The semaphore_wait function decrements the semaphore count. If the semaphore count is negative after decrementing, the calling thread blocks. Device driver interrupt service routines (ISR) should never execute semaphore_wait, since waiting on a semaphore at the ISR level may, and often will, lead to a deadlock.

### RETURN VALUES

KERN_INVALID_ARGUMENT
  The specified semaphore is invalid.

KERN_TERMINATED
  The specified semaphore has been destroyed.

KERN_ABORTED
  The caller was blocked due to a negative count on the semaphore, and was awoken for a reason not related to the semaphore subsystem (e.g. thread_terminate).

KERN_SUCCESS
  The semaphore wait operation was successful.

### RELATED INFORMATION

Functions: semaphore_create, semaphore_destroy, semaphore_signal, semaphore_signal_all, device_get_status.