.Dt SEM_WAIT 2
.Os Darwin
.Sh NAME
-.Nm sem_wait, sem_trywait
+.Nm sem_trywait, sem_wait
.Nd lock a semaphore
.Sh SYNOPSIS
.Fd #include <semaphore.h>
.Ft int
-.Fn sem_wait "sem_t *sem"
-.Ft int
.Fn sem_trywait "sem_t *sem"
+.Ft int
+.Fn sem_wait "sem_t *sem"
.Sh DESCRIPTION
The semaphore referenced by
.Fa sem
is locked. When calling
.Fn sem_wait ,
if the semaphore's value is zero, the calling thread will block until
-the lock is aquired or until the call is interrupted by a
+the lock is acquired or until the call is interrupted by a
signal. Alternatively, the
.Fn sem_trywait
function will fail if the semaphore is already locked, rather than
blocking on the semaphore.
.Pp
-If successful (the lock was aquired),
+If successful (the lock was acquired),
.Fn sem_wait
and
.Fn sem_trywait
.Bl -tag -width Er
.It Bq Er EAGAIN
The semaphore is already locked.
-.It Bq Er EINVAL
-.Fa sem
-is not a valid semaphore descriptor.
.It Bq Er EDEADLK
A deadlock was detected.
.It Bq Er EINTR
The call was interrupted by a signal.
+.It Bq Er EINVAL
+.Fa sem
+is not a valid semaphore descriptor.
.El
.Sh NOTES
Applications may encounter a priority inversion while using
unlimited time period. Programmers using the realtime functionality
of the system should take care to avoid priority inversions.
.Sh SEE ALSO
+.Xr sem_open 2 ,
+.Xr sem_post 2 ,
.Xr semctl 2 ,
.Xr semget 2 ,
-.Xr semop 2 ,
-.Xr sem_open 2 ,
-.Xr sem_post 2
+.Xr semop 2
.Sh HISTORY
.Fn sem_wait
and