NAME

sem_post - increment the count of a semaphore

SYNOPSIS

#include <semaphore.h>

int sem_post(sem_t *sem );

Callable from ISR.

typedef struct {
...
} sem_t /*opaque POSIX semaphore*/

DESCRIPTION

If, prior to the call to sem_post(), the value of sem was 0, and other threads were blocked waiting for the semaphore, then one of them will be allowed to return successfully from its call to sem_wait(). The thread which has been waiting the longest is unblocked.

If, prior to the call to sem_post(), no other threads were blocked for the semaphore, then its value is incremented by one.

RETURN VALUES

If successful, sem_post() returns 0, otherwise it returns -1, and sets errno to indicate the error condition.

ERRORS

EINVAL
sem does not refer to a valid semaphore.

SEE ALSO

sem_wait()

Home page (Kernel)


< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2018 >