Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Macros | Functions
semaphore.h File Reference
#include <stdint.h>
Include dependency graph for semaphore.h:

Go to the source code of this file.

Data Structures

union  sem_t
 

Macros

#define __SIZEOF_SEM_T   12 /* sizeof(struct semaphore) */
 

Functions

int sem_init (sem_t *sem, int pshared, unsigned int value)
 Initialize the semaphore. More...
 
int sem_destroy (sem_t *sem)
 Destroy the semaphore. More...
 
int sem_post (sem_t *sem)
 Increase the value of the semaphore. More...
 
int sem_trywait (sem_t *sem)
 The same as sem_wait(), except that if the decrement cannot be immediately performed, then the function returns an error instead of blocking. More...
 
int sem_wait (sem_t *sem)
 Decrement the value of the semaphore. If the semaphore currently has the value zero, then the function blocks until it becomes possible to perform the decrement. More...
 
int sem_getvalue (sem_t *sem, int *sval)
 Get the value of the semaphore. More...
 

Function Documentation

◆ sem_destroy()

int sem_destroy ( sem_t sem)

Destroy the semaphore.

Parameters
semPointer to the semaphore.
Return values
int0 on success and nonzero error number on error.

◆ sem_getvalue()

int sem_getvalue ( sem_t sem,
int *  sval 
)

Get the value of the semaphore.

Parameters
semThe semaphore object to provide.
svalFor returning current value of the semaphore.
Return values
int0 on success and nonzero error number on error.

◆ sem_init()

int sem_init ( sem_t sem,
int  pshared,
unsigned int  value 
)

Initialize the semaphore.

Parameters
semPointer to the semaphore.
psharedNot used.
valueThe initial value of the semaphore.
Return values
int0 on success and nonzero error number on error.

◆ sem_post()

int sem_post ( sem_t sem)

Increase the value of the semaphore.

Parameters
semPointer to the semaphore.
Return values
int0 on success and nonzero error number on error.

◆ sem_trywait()

int sem_trywait ( sem_t sem)

The same as sem_wait(), except that if the decrement cannot be immediately performed, then the function returns an error instead of blocking.

Parameters
semPointer to the semaphore.
Return values
int0 on success and nonzero error number on error.

◆ sem_wait()

int sem_wait ( sem_t sem)

Decrement the value of the semaphore. If the semaphore currently has the value zero, then the function blocks until it becomes possible to perform the decrement.

Parameters
semPointer to the semaphore.
Return values
int0 on success and nonzero error number on error.