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

Go to the source code of this file.

Data Structures

struct  semaphore
 

Functions

void sema_init (struct semaphore *sem, int val)
 Initialize the semaphore. More...
 
int down (struct semaphore *sem)
 Decrease the number of the semaphore. More...
 
int down_trylock (struct semaphore *sem)
 The same as down(), except that if the decrement cannot be immediately performed, then call returns an error instead of blocking. More...
 
int up (struct semaphore *sem)
 Increase the number of the semaphore. More...
 

Function Documentation

◆ down()

int down ( struct semaphore sem)

Decrease the number of the semaphore.

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

◆ down_trylock()

int down_trylock ( struct semaphore sem)

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

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

◆ sema_init()

void sema_init ( struct semaphore sem,
int  val 
)

Initialize the semaphore.

Parameters
semPointer to the semaphore.
valInitial value of the semaphore.
Return values
None

◆ up()

int up ( struct semaphore sem)

Increase the number of the semaphore.

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