Files | |
file | sem.c |
Semaphore functions. | |
Defines | |
#define | WAKEUP_WAIT_ONE_POLLER(wakeup) |
#define | WAKEUP_WAIT_ALL_POLLERS(wakeup) |
#define | CHECK_SEM_MAGIC(sem) do { if (sem->magic != RT_SEM_MAGIC) return RTE_OBJINV; } while (0) |
Functions | |
MODULE_LICENSE ("GPL") | |
RTAI_SYSCALL_MODE void | rt_typed_sem_init (SEM *sem, int value, int type) |
Initialize a specifically typed (counting, binary, resource) semaphore | |
void | rt_sem_init (SEM *sem, int value) |
Initialize a counting semaphore. | |
RTAI_SYSCALL_MODE int | rt_sem_delete (SEM *sem) |
Delete a semaphore | |
RTAI_SYSCALL_MODE int | rt_sem_count (SEM *sem) |
RTAI_SYSCALL_MODE int | rt_sem_signal (SEM *sem) |
Signaling a semaphore. | |
RTAI_SYSCALL_MODE int | rt_sem_broadcast (SEM *sem) |
Signaling a semaphore. | |
RTAI_SYSCALL_MODE int | rt_sem_wait (SEM *sem) |
Take a semaphore. | |
RTAI_SYSCALL_MODE int | rt_sem_wait_if (SEM *sem) |
Take a semaphore, only if the calling task is not blocked. | |
RTAI_SYSCALL_MODE int | rt_sem_wait_until (SEM *sem, RTIME time) |
Wait a semaphore with timeout. | |
RTAI_SYSCALL_MODE int | rt_sem_wait_timed (SEM *sem, RTIME delay) |
Wait a semaphore with timeout. | |
RTAI_SYSCALL_MODE int | rt_sem_wait_barrier (SEM *sem) |
Wait on a semaphore barrier. | |
RTAI_SYSCALL_MODE int | rt_cond_signal (CND *cnd) |
Wait for a signal to a conditional variable. | |
static int | rt_cndmtx_signal (SEM *mtx, RT_TASK *rt_current) |
RTAI_SYSCALL_MODE int | rt_cond_wait (CND *cnd, SEM *mtx) |
Wait for a signal to a conditional variable. | |
RTAI_SYSCALL_MODE int | rt_cond_wait_until (CND *cnd, SEM *mtx, RTIME time) |
Wait a semaphore with timeout. | |
RTAI_SYSCALL_MODE int | rt_cond_wait_timed (CND *cnd, SEM *mtx, RTIME delay) |
Wait a semaphore with timeout. | |
RTAI_SYSCALL_MODE int | rt_typed_rwl_init (RWL *rwl, int type) |
Initialize a multi readers single writer lock. | |
RTAI_SYSCALL_MODE int | rt_rwl_delete (RWL *rwl) |
destroys a multi readers single writer lock. | |
RTAI_SYSCALL_MODE int | rt_rwl_rdlock (RWL *rwl) |
acquires a multi readers single writer lock for reading. | |
RTAI_SYSCALL_MODE int | rt_rwl_rdlock_if (RWL *rwl) |
try to acquire a multi readers single writer lock just for reading. | |
RTAI_SYSCALL_MODE int | rt_rwl_rdlock_until (RWL *rwl, RTIME time) |
try to acquire a multi readers single writer lock for reading within an absolute deadline time. | |
RTAI_SYSCALL_MODE int | rt_rwl_rdlock_timed (RWL *rwl, RTIME delay) |
try to acquire a multi readers single writer lock for reading within a relative deadline time. | |
RTAI_SYSCALL_MODE int | rt_rwl_wrlock (RWL *rwl) |
acquires a multi readers single writer lock for wrtiting. | |
RTAI_SYSCALL_MODE int | rt_rwl_wrlock_if (RWL *rwl) |
acquires a multi readers single writer lock for writing. | |
RTAI_SYSCALL_MODE int | rt_rwl_wrlock_until (RWL *rwl, RTIME time) |
try to acquire a multi readers single writer lock for writing within an absolute deadline time. | |
RTAI_SYSCALL_MODE int | rt_rwl_wrlock_timed (RWL *rwl, RTIME delay) |
try to acquire a multi readers single writer lock for writing within a relative deadline time. | |
RTAI_SYSCALL_MODE int | rt_rwl_unlock (RWL *rwl) |
unlock an acquired multi readers single writer lock. | |
RTAI_SYSCALL_MODE int | rt_spl_init (SPL *spl) |
Initialize a spinlock. | |
RTAI_SYSCALL_MODE int | rt_spl_delete (SPL *spl) |
Initialize a spinlock. | |
RTAI_SYSCALL_MODE int | rt_spl_lock (SPL *spl) |
Acquire a spinlock. | |
RTAI_SYSCALL_MODE int | rt_spl_lock_if (SPL *spl) |
Acquire a spinlock without waiting. | |
RTAI_SYSCALL_MODE int | rt_spl_lock_timed (SPL *spl, unsigned long ns) |
Acquire a spinlock with timeout. | |
RTAI_SYSCALL_MODE int | rt_spl_unlock (SPL *spl) |
Release an owned spinlock. | |
RTAI_SYSCALL_MODE SEM * | _rt_typed_named_sem_init (unsigned long sem_name, int value, int type, unsigned long *handle) |
Initialize a specifically typed (counting, binary, resource) semaphore identified by a name. | |
RTAI_SYSCALL_MODE int | rt_named_sem_delete (SEM *sem) |
Delete a semaphore initialized in named mode. | |
RTAI_SYSCALL_MODE RWL * | _rt_named_rwl_init (unsigned long rwl_name) |
Initialize a multi readers single writer lock identified by a name. | |
RTAI_SYSCALL_MODE int | rt_named_rwl_delete (RWL *rwl) |
Delete a multi readers single writer lock in named mode. | |
RTAI_SYSCALL_MODE SPL * | _rt_named_spl_init (unsigned long spl_name) |
Initialize a spinlock identified by a name. | |
RTAI_SYSCALL_MODE int | rt_named_spl_delete (SPL *spl) |
Delete a spinlock in named mode. | |
EXPORT_SYMBOL (rt_poll_ofstfun) | |
int | set_rt_fun_entries (struct rt_native_fun_entry *entry) |
void | reset_rt_fun_entries (struct rt_native_fun_entry *entry) |
static int | poll_wait (void *sem) |
int | __rtai_sem_init (void) |
void | __rtai_sem_exit (void) |
Variables | |
epoch_struct | boot_epoch |
rt_poll_enc | rt_poll_ofstfun [] |
rt_native_fun_entry | rt_sem_entries [] |
#define CHECK_SEM_MAGIC | ( | sem | ) | do { if (sem->magic != RT_SEM_MAGIC) return RTE_OBJINV; } while (0) |
Definition at line 66 of file sem.c.
Referenced by rt_cond_signal(), rt_cond_wait(), rt_cond_wait_until(), rt_sem_broadcast(), rt_sem_delete(), rt_sem_signal(), rt_sem_wait(), rt_sem_wait_barrier(), rt_sem_wait_if(), and rt_sem_wait_until().
#define WAKEUP_WAIT_ALL_POLLERS | ( | wakeup | ) |
#define WAKEUP_WAIT_ONE_POLLER | ( | wakeup | ) |
void __rtai_sem_exit | ( | void | ) |
Definition at line 2146 of file sem.c.
References reset_rt_fun_entries(), rt_poll_ofstfun, RT_POLL_SEM_WAIT_ALL, and RT_POLL_SEM_WAIT_ONE.
Here is the call graph for this function:
int __rtai_sem_init | ( | void | ) |
Definition at line 2139 of file sem.c.
References poll_wait(), rt_poll_ofstfun, RT_POLL_SEM_WAIT_ALL, RT_POLL_SEM_WAIT_ONE, and set_rt_fun_entries().
Here is the call graph for this function:
RTAI_SYSCALL_MODE RWL* _rt_named_rwl_init | ( | unsigned long | rwl_name | ) |
Initialize a multi readers single writer lock identified by a name.
_rt_named_rwl_init allocate and initializes a multi readers single writer lock (RWL) identified by name. Once the lock structure is allocated the initialization is as for rt_rwl_init. The function returns the handle pointing to the allocated multi readers single writer lock o structure, to be used as the usual lock address in all rwl based services. Named objects are useful for use among different processes, kernel/user space and in distributed applications, see netrpc.
rwl_name | is the identifier associated with the returned object. |
Definition at line 1656 of file sem.c.
References IS_RWL, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_rwl_delete(), and rt_rwl_init.
Here is the call graph for this function:
RTAI_SYSCALL_MODE SPL* _rt_named_spl_init | ( | unsigned long | spl_name | ) |
Initialize a spinlock identified by a name.
_rt_named_spl_init allocate and initializes a spinlock (SPL) identified by name. Once the spinlock structure is allocated the initialization is as for rt_spl_init. The function returns the handle pointing to the allocated spinlock structure, to be used as the usual spinlock address in all spinlock based services. Named objects are useful for use among different processes and kernel/user space.
spl_name | is the identifier associated with the returned object. |
Definition at line 1736 of file sem.c.
References IS_SPL, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_spl_delete(), and rt_spl_init().
Here is the call graph for this function:
RTAI_SYSCALL_MODE SEM* _rt_typed_named_sem_init | ( | unsigned long | sem_name, | |
int | value, | |||
int | type, | |||
unsigned long * | handle | |||
) |
Initialize a specifically typed (counting, binary, resource) semaphore identified by a name.
_rt_typed_named_sem_init allocate and initializes a semaphore identified by name of type type. Once the semaphore structure is allocated the initialization is as for rt_typed_sem_init. The function returns the handle pointing to the allocated semaphore structure, to be used as the usual semaphore address in all semaphore based services. Named objects are useful for use among different processes, kernel/user space and in distributed applications, see netrpc.
sem_name | is the identifier associated with the returned object. | |
value | is the initial value of the semaphore, always set to 1 for a resource semaphore. | |
type | is the semaphore type and queuing policy. It can be an OR a semaphore kind: CNT_SEM for counting semaphores, BIN_SEM for binary semaphores, RES_SEM for resource semaphores; and queuing policy: FIFO_Q, PRIO_Q for a fifo and priority queueing respectively. Resource semaphores will enforce a PRIO_Q policy anyhow. |
As for all the named initialization functions it must be remarked that only the very first call to initilize/create a named RTAI object does a real allocation of the object, any following call with the same name will just increase its usage count. In any case the function returns a pointer to the named object, or zero if in error.
Definition at line 1567 of file sem.c.
References IS_SEM, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_sem_delete(), and rt_typed_sem_init().
Here is the call graph for this function:
EXPORT_SYMBOL | ( | rt_poll_ofstfun | ) |
MODULE_LICENSE | ( | "GPL" | ) |
static int poll_wait | ( | void * | sem | ) | [static] |
void reset_rt_fun_entries | ( | struct rt_native_fun_entry * | entry | ) |
Definition at line 792 of file sem.c.
References dequeue_blocked(), RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, rt_schedule(), and task.
Referenced by rt_cond_wait(), and rt_cond_wait_until().
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_cond_signal | ( | CND * | cnd | ) |
Wait for a signal to a conditional variable.
rt_cond_signal resumes one of the tasks that are waiting on the condition semaphore cnd. Nothing happens if no task is waiting on cnd, while it resumed the first queued task blocked on cnd, according to the queueing method set at rt_cond_init.
cnd | points to the structure used in the call to rt_cond_init(). |
Definition at line 772 of file sem.c.
References CHECK_SEM_MAGIC, dequeue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, and task.
Here is the call graph for this function:
Wait for a signal to a conditional variable.
rt_cond_wait atomically unlocks mtx (as for using rt_sem_signal) and waits for the condition semaphore cnd to be signaled. The task execution is suspended until the condition semaphore is signalled. Mtx must be obtained by the calling task, before calling rt_cond_wait is called. Before returning to the calling task rt_cond_wait reacquires mtx by calling rt_sem_wait.
cnd | points to the structure used in the call to rt_cond_init(). | |
mtx | points to the structure used in the call to rt_sem_init(). |
Definition at line 840 of file sem.c.
References CHECK_SEM_MAGIC, dequeue_blocked(), enqueue_blocked(), flags, likely, rt_cndmtx_signal(), RT_SCHED_SEMAPHORE, rt_sem_wait(), RTE_LOWERR, RTE_OBJREM, RTE_PERM, RTE_UNBLKD, RTP_OBJREM, and unlikely.
Here is the call graph for this function:
Wait a semaphore with timeout.
rt_cond_wait_timed atomically unlocks mtx (as for using rt_sem_signal) and waits for the condition semaphore cnd to be signalled. The task execution is suspended until the condition semaphore is either signaled or a timeout expires. Mtx must be obtained by the calling task, before calling rt_cond_wait is called. Before returning to the calling task rt_cond_wait_until reacquires mtx by calling rt_sem_wait and returns a value to indicate if it has been signalled pr timedout.
cnd | points to the structure used in the call to rt_cond_init(). | |
mtx | points to the structure used in the call to rt_sem_init(). | |
delay | is a realtive time values with respect to the current time, in timer count unit. |
Definition at line 969 of file sem.c.
References rt_cond_wait_until().
Here is the call graph for this function:
Wait a semaphore with timeout.
rt_cond_wait_until atomically unlocks mtx (as for using rt_sem_signal) and waits for the condition semaphore cnd to be signalled. The task execution is suspended until the condition semaphore is either signaled or a timeout expires. Mtx must be obtained by the calling task, before calling rt_cond_wait is called. Before returning to the calling task rt_cond_wait_until reacquires mtx by calling rt_sem_wait and returns a value to indicate if it has been signalled pr timedout.
cnd | points to the structure used in the call to rt_cond_init(). | |
mtx | points to the structure used in the call to rt_sem_init(). | |
time | is an absolute value to the current time, in timer count unit. |
Definition at line 901 of file sem.c.
References CHECK_SEM_MAGIC, dequeue_blocked(), enqueue_blocked(), flags, likely, rt_cndmtx_signal(), RT_SCHED_DELAYED, RT_SCHED_SEMAPHORE, rt_sem_wait(), RTE_LOWERR, RTE_OBJREM, RTE_PERM, RTE_TIMOUT, RTE_UNBLKD, RTP_HIGERR, RTP_OBJREM, and unlikely.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_named_rwl_delete | ( | RWL * | rwl | ) |
Delete a multi readers single writer lock in named mode.
rt_named_rwl_delete deletes a multi readers single writer lock previously created with _rt_named_rwl_init().
rwl | points to the structure pointer returned by a corresponding call to rt_named_rwl_init. |
Definition at line 1694 of file sem.c.
References rt_drg_on_adr_cnt(), rt_free(), rt_rwl_delete(), and RTE_OBJINV.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_named_sem_delete | ( | SEM * | sem | ) |
Delete a semaphore initialized in named mode.
rt_named_sem_delete deletes a semaphore previously created with _rt_typed_named_sem_init().
sem | points to the structure pointer returned by a corresponding call to _rt_typed_named_sem_init. |
Definition at line 1613 of file sem.c.
References rt_drg_on_adr_cnt(), rt_free(), rt_sem_delete(), and RTE_OBJINV.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_named_spl_delete | ( | SPL * | spl | ) |
Delete a spinlock in named mode.
rt_named_spl_delete deletes a spinlock previously created with _rt_named_spl_init().
spl | points to the structure pointer returned by a corresponding call to rt_named_spl_init. |
Definition at line 1773 of file sem.c.
References rt_drg_on_adr_cnt(), rt_free(), and rt_spl_delete().
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_delete | ( | RWL * | rwl | ) |
destroys a multi readers single writer lock.
rt_rwl_init destroys a multi readers single writer lock rwl.
rwl | must point to an allocated RWL structure. |
Definition at line 1015 of file sem.c.
References rt_sem_delete(), and RTE_OBJINV.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_rdlock | ( | RWL * | rwl | ) |
acquires a multi readers single writer lock for reading.
rt_rwl_rdlock acquires a multi readers single writer lock rwl for reading. The calling task will block only if any writer owns the lock already or there are writers with higher priority waiting to acquire write access.
rwl | must point to an allocated RWL structure. |
Definition at line 1040 of file sem.c.
References flags, rt_sem_wait(), RTE_LOWERR, and RTE_RWLINV.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_rdlock_if | ( | RWL * | rwl | ) |
try to acquire a multi readers single writer lock just for reading.
rt_rwl_rdlock_if tries to acquire a multi readers single writer lock rwl for reading immediately, i.e. without blocking if a writer owns the lock or there are writers with higher priority waiting to acquire write access.
rwl | must point to an allocated RWL structure. |
Definition at line 1077 of file sem.c.
References flags.
try to acquire a multi readers single writer lock for reading within a relative deadline time.
rt_rwl_rdlock_timed tries to acquire a multi readers single writer lock rwl for reading, as for rt_rwl_rdlock, but timing out if the lock has not been acquired within an assigned deadline.
rwl | must point to an allocated RWL structure. | |
delay | is the time delay within which the lock must be acquired, in internal count units. |
Definition at line 1152 of file sem.c.
References rt_rwl_rdlock_until().
Here is the call graph for this function:
try to acquire a multi readers single writer lock for reading within an absolute deadline time.
rt_rwl_rdlock_untill tries to acquire a multi readers single writer lock rwl for reading, as for rt_rwl_rdlock, but timing out if the lock has not been acquired within an assigned deadline.
rwl | must point to an allocated RWL structure. | |
time | is the time deadline, in internal count units. |
Definition at line 1110 of file sem.c.
References flags, rt_sem_wait_until(), RTE_LOWERR, and RTE_RWLINV.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_unlock | ( | RWL * | rwl | ) |
unlock an acquired multi readers single writer lock.
rt_rwl_unlock unlocks an acquired multi readers single writer lock rwl. After releasing the lock any task waiting to acquire it will own the lock according to its priority, whether it is a reader or a writer, otherwise the lock will be fully unlocked.
rwl | must point to an allocated RWL structure. |
Definition at line 1295 of file sem.c.
References flags, rt_sem_broadcast(), rt_sem_signal(), rtask, RTE_PERM, and task.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_wrlock | ( | RWL * | rwl | ) |
acquires a multi readers single writer lock for wrtiting.
rt_rwl_rwlock acquires a multi readers single writer lock rwl for writing. The calling task will block if any other task, reader or writer, owns the lock already.
rwl | must point to an allocated RWL structure. |
Definition at line 1171 of file sem.c.
References flags, rt_sem_wait(), and RTE_LOWERR.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_rwl_wrlock_if | ( | RWL * | rwl | ) |
acquires a multi readers single writer lock for writing.
rt_rwl_wrlock_if try to acquire a multi readers single writer lock rwl for writing immediately, i.e without blocking if the lock is owned already.
rwl | must point to an allocated RWL structure. |
Definition at line 1204 of file sem.c.
References flags, rt_sem_wait_if(), and RTE_LOWERR.
Here is the call graph for this function:
try to acquire a multi readers single writer lock for writing within a relative deadline time.
rt_rwl_wrlock_timed tries to acquire a multi readers single writer lock rwl for writing, as for rt_rwl_wrlock, timing out if the lock has not been acquired within an assigned deadline.
rwl | must point to an allocated RWL structure. | |
delay | is the time delay within which the lock must be acquired, in internal count units. |
Definition at line 1275 of file sem.c.
References rt_rwl_wrlock_until().
Here is the call graph for this function:
try to acquire a multi readers single writer lock for writing within an absolute deadline time.
rt_rwl_rwlock_until tries to acquire a multi readers single writer lock rwl for writing, as for rt_rwl_rwlock, but timing out if the lock has not been acquired within an assigned deadline.
rwl | must point to an allocated RWL structure. | |
time | is the time deadline, in internal count units. |
Definition at line 1236 of file sem.c.
References flags, rt_sem_wait_until(), and RTE_LOWERR.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_broadcast | ( | SEM * | sem | ) |
rt_sem_broadcast signals an event to a semaphore that unblocks all tasks waiting on it. It is used as a support for RTAI proper conditional variables but can be of help in many other instances. After the broadcast the semaphore counts is set to zero, thus all tasks waiting on it will blocked. rt_sem_broadcast should not be used for resource semaphares.
sem | points to the structure used in the call to rt_sem_init(). |
Definition at line 386 of file sem.c.
References CHECK_SEM_MAGIC, dequeue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, task, and WAKEUP_WAIT_ONE_POLLER.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_delete | ( | SEM * | sem | ) |
rt_sem_delete deletes a semaphore previously created with rt_sem_init().
sem | points to the structure used in the corresponding call to rt_sem_init. |
Definition at line 219 of file sem.c.
References CHECK_SEM_MAGIC, flags, RT_RESEM_SUSPDEL, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SCHED_SUSPENDED, rt_schedule(), rt_task_delete, RTE_OBJREM, RTP_OBJREM, and task.
Here is the call graph for this function:
void rt_sem_init | ( | SEM * | sem, | |
int | value | |||
) |
Initialize a counting semaphore.
rt_sem_init initializes a counting fifo queueing semaphore sem.
A semaphore can be used for communication and synchronization among real time tasks.
sem | must point to an allocated SEM structure. | |
value | is the initial value of the semaphore. |
Definition at line 190 of file sem.c.
References CNT_SEM, and rt_typed_sem_init().
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_signal | ( | SEM * | sem | ) |
rt_sem_signal signals an event to a semaphore. It is typically called when the task leaves a critical region. The semaphore value is incremented and tested. If the value is not positive, the first task in semaphore's waiting queue is allowed to run. rt_sem_signal never blocks the caller task.
sem | points to the structure used in the call to rt_sem_init(). |
Definition at line 298 of file sem.c.
References CHECK_SEM_MAGIC, cpuid, dequeue_blocked(), flags, RT_RESEM_SUSPDEL, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SCHED_SUSPENDED, rt_schedule(), rt_task_delete, RTE_PERM, task, and WAKEUP_WAIT_ALL_POLLERS.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_wait | ( | SEM * | sem | ) |
rt_sem_wait waits for a event to be signaled to a semaphore. It is typically called when a task enters a critical region. The semaphore value is decremented and tested. If it is still non-negative rt_sem_wait returns immediately. Otherwise the caller task is blocked and queued up. Queuing may happen in priority order or on FIFO base. This is determined by the compile time option SEM_PRIORD. In this case rt_sem_wait returns if:
sem | points to the structure used in the call to rt_sem_init(). |
Definition at line 465 of file sem.c.
References CHECK_SEM_MAGIC, count, dequeue_blocked(), enqueue_blocked(), flags, likely, RT_SCHED_SEMAPHORE, RTE_DEADLOK, RTE_OBJREM, RTE_UNBLKD, and RTP_OBJREM.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_wait_barrier | ( | SEM * | sem | ) |
rt_sem_wait_barrier is a gang waiting in that a task issuing such a request will be blocked till a number of tasks equal to the semaphore count set at rt_sem_init is reached.
Definition at line 734 of file sem.c.
References CHECK_SEM_MAGIC, flags, rt_sem_broadcast(), and rt_sem_wait().
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_sem_wait_if | ( | SEM * | sem | ) |
Take a semaphore, only if the calling task is not blocked.
rt_sem_wait_if is a version of the semaphore wait operation is similar to rt_sem_wait() but it is never blocks the caller. If the semaphore is not free, rt_sem_wait_if returns immediately and the semaphore value remains unchanged.
sem | points to the structure used in the call to rt_sem_init(). |
Definition at line 549 of file sem.c.
References CHECK_SEM_MAGIC, count, flags, and RTE_DEADLOK.
Wait a semaphore with timeout.
rt_sem_wait_timed, like rt_sem_wait_until(), is a timed version of the standard semaphore wait call. The semaphore value is decremented and tested. If it is still non-negative these functions return immediately. Otherwise the caller task is blocked and queued up. Queuing may happen in priority order or on FIFO base. This is determined by the compile time option SEM_PRIORD. In this case the function returns if:
In case of a timeout, the semaphore value is incremented before return.
sem | points to the structure used in the call to rt_sem_init(). | |
delay | is an absolute value to the current time. |
Definition at line 715 of file sem.c.
References rt_sem_wait_until().
Here is the call graph for this function:
Wait a semaphore with timeout.
rt_sem_wait_until, like rt_sem_wait_timed() is a timed version of the standard semaphore wait call. The semaphore value is decremented and tested. If it is still non-negative these functions return immediately. Otherwise the caller task is blocked and queued up. Queuing may happen in priority order or on FIFO base. This is determined by the compile time option SEM_PRIORD. In this case the function returns if:
In case of a timeout, the semaphore value is incremented before return.
sem | points to the structure used in the call to rt_sem_init(). | |
time | is an absolute value to the current time. |
Definition at line 612 of file sem.c.
References CHECK_SEM_MAGIC, count, dequeue_blocked(), enqueue_blocked(), flags, likely, RT_SCHED_DELAYED, RT_SCHED_SEMAPHORE, RTE_DEADLOK, RTE_OBJREM, RTE_TIMOUT, RTE_UNBLKD, RTP_HIGERR, and RTP_OBJREM.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_spl_delete | ( | SPL * | spl | ) |
RTAI_SYSCALL_MODE int rt_spl_init | ( | SPL * | spl | ) |
rt_spl_init initializes a spinlock spl.
spl | must point to an allocated SPL structure. |
RTAI_SYSCALL_MODE int rt_spl_lock | ( | SPL * | spl | ) |
rt_spl_lock acquires a spinlock spl.
spl | must point to an allocated SPL structure. |
Definition at line 1391 of file sem.c.
References cmpxchg, flags, rtai_restore_flags, and rtai_save_flags_and_cli.
RTAI_SYSCALL_MODE int rt_spl_lock_if | ( | SPL * | spl | ) |
Acquire a spinlock without waiting.
rt_spl_lock_if acquires a spinlock spl without waiting.
spl | must point to an allocated SPL structure. |
Definition at line 1422 of file sem.c.
References cmpxchg, flags, rtai_restore_flags, and rtai_save_flags_and_cli.
RTAI_SYSCALL_MODE int rt_spl_lock_timed | ( | SPL * | spl, | |
unsigned long | ns | |||
) |
Acquire a spinlock with timeout.
rt_spl_lock_timed acquires a spinlock spl, but waiting spinning only for an allowed time.
spl | must point to an allocated SPL structure. | |
ns | timeout |
Definition at line 1462 of file sem.c.
References cmpxchg, flags, imuldiv(), locked, rdtsc, rtai_restore_flags, rtai_save_flags_and_cli, and tuned.
Here is the call graph for this function:
RTAI_SYSCALL_MODE int rt_spl_unlock | ( | SPL * | spl | ) |
rt_spl_lock releases an owned spinlock spl.
spl | must point to an allocated SPL structure. |
Definition at line 1502 of file sem.c.
References flags, rtai_restore_flags, and rtai_save_flags_and_cli.
RTAI_SYSCALL_MODE int rt_typed_rwl_init | ( | RWL * | rwl, | |
int | type | |||
) |
Initialize a multi readers single writer lock.
rt_rwl_init initializes a multi readers single writer lock rwl.
rwl | must point to an allocated RWL structure. |
Definition at line 995 of file sem.c.
References CNT_SEM, PRIO_Q, RES_SEM, and rt_typed_sem_init().
Here is the call graph for this function:
RTAI_SYSCALL_MODE void rt_typed_sem_init | ( | SEM * | sem, | |
int | value, | |||
int | type | |||
) |
Initialize a specifically typed (counting, binary, resource) semaphore
rt_typed_sem_init initializes a semaphore sem of type type. A semaphore can be used for communication and synchronization among real time tasks. Negative value of a semaphore shows how many tasks are blocked on the semaphore queue, waiting to be awaken by calls to rt_sem_signal.
sem | must point to an allocated SEM structure. | |
value | is the initial value of the semaphore, always set to 1 for a resource semaphore. | |
type | is the semaphore type and queuing policy. It can be an OR a semaphore kind: CNT_SEM for counting semaphores, BIN_SEM for binary semaphores, RES_SEM for resource semaphores; and queuing policy: FIFO_Q, PRIO_Q for a fifo and priority queueing respectively. Resource semaphores will enforce a PRIO_Q policy anyhow. |
Definition at line 130 of file sem.c.
References FIFO_Q, RES_SEM, and RT_SEM_MAGIC.
int set_rt_fun_entries | ( | struct rt_native_fun_entry * | entry | ) |
struct epoch_struct boot_epoch |
struct rt_poll_enc rt_poll_ofstfun[] |
Initial value:
{ [RT_POLL_NOT_TO_USE] = { 0 , NULL }, [RT_POLL_MBX_RECV] = { 0, NULL }, [RT_POLL_MBX_SEND] = { 0, NULL }, [RT_POLL_SEM_WAIT_ALL] = { 0, NULL }, [RT_POLL_SEM_WAIT_ONE] = { 0, NULL } }
Definition at line 1786 of file sem.c.
Referenced by __rtai_mbx_exit(), __rtai_mbx_init(), __rtai_sem_exit(), and __rtai_sem_init().
struct rt_native_fun_entry rt_sem_entries[] |