rt_sem_init2
Create a semaphore
Usage
#define MODULE #include <linux/module.h> #include <linux/kernel.h> #include <linux/version.h> #include <linux/errno.h> #include rt_ipc.h
int rt_sem_init(rt_sem_t *sem, RT_SEMTYPE type, int init_val);
Overview
rt_sem_init is called to initialize a real-time semaphore. A semaphore can be used for communication and synchronization among real-time tasks. Communication between Linux processes and real-time tasks is done using the standard Real-Time Linux RT-FIFO facilities.
sem must point to a statically allocated structure. type is RT_SEM_BINARY or RT_SEM_COUNTING. init_val is the initial value of the semaphore (usually 0).
Return value
On success, 0 is returned. On failure, a negative value is returned as described below.
Errors
-EINVAL-
init_val is negative (or type is RT_SEM_BINARY, and init_val is greater than one.