Files | |
file | sem.c |
Semaphore functions. | |
Functions | |
MODULE_LICENSE ("GPL") | |
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. | |
int | rt_sem_delete (SEM *sem) |
Delete a semaphore. | |
int | rt_sem_count (SEM *sem) |
int | rt_sem_signal (SEM *sem) |
Signaling a semaphore. | |
int | rt_sem_broadcast (SEM *sem) |
Signaling a semaphore. | |
int | rt_sem_wait (SEM *sem) |
Take a semaphore. | |
int | rt_sem_wait_if (SEM *sem) |
Take a semaphore, only if the calling task is not blocked. | |
int | rt_sem_wait_until (SEM *sem, RTIME time) |
Wait a semaphore with timeout. | |
int | rt_sem_wait_timed (SEM *sem, RTIME delay) |
Wait a semaphore with timeout. | |
int | rt_sem_wait_barrier (SEM *sem) |
Wait on a semaphore barrier. | |
int | rt_cond_signal (CND *cnd) |
Wait for a signal to a conditional variable. | |
int | rt_cndmtx_signal (SEM *mtx, RT_TASK *rt_current) |
int | rt_cond_wait (CND *cnd, SEM *mtx) |
Wait for a signal to a conditional variable. | |
int | rt_cond_wait_until (CND *cnd, SEM *mtx, RTIME time) |
Wait a semaphore with timeout. | |
int | rt_cond_wait_timed (CND *cnd, SEM *mtx, RTIME delay) |
Wait a semaphore with timeout. | |
int | rt_rwl_init (RWL *rwl) |
Initialize a multi readers single writer lock. | |
int | rt_rwl_delete (RWL *rwl) |
destroys a multi readers single writer lock. | |
int | rt_rwl_rdlock (RWL *rwl) |
acquires a multi readers single writer lock for reading. | |
int | rt_rwl_rdlock_if (RWL *rwl) |
try to acquire a multi readers single writer lock just for reading. | |
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. | |
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. | |
int | rt_rwl_wrlock (RWL *rwl) |
acquires a multi readers single writer lock for wrtiting. | |
int | rt_rwl_wrlock_if (RWL *rwl) |
acquires a multi readers single writer lock for writing. | |
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. | |
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. | |
int | rt_rwl_unlock (RWL *rwl) |
unlock an acquired multi readers single writer lock. | |
int | rt_spl_init (SPL *spl) |
Initialize a spinlock. | |
int | rt_spl_delete (SPL *spl) |
Initialize a spinlock. | |
int | rt_spl_lock (SPL *spl) |
Acquire a spinlock. | |
int | rt_spl_lock_if (SPL *spl) |
Acquire a spinlock without waiting. | |
int | rt_spl_lock_timed (SPL *spl, unsigned long ns) |
Acquire a spinlock with timeout. | |
int | rt_spl_unlock (SPL *spl) |
Release an owned spinlock. | |
SEM * | _rt_typed_named_sem_init (unsigned long sem_name, int value, int type) |
Initialize a specifically typed (counting, binary, resource) semaphore identified by a name. | |
int | rt_named_sem_delete (SEM *sem) |
Delete a semaphore initialized in named mode. | |
RWL * | _rt_named_rwl_init (unsigned long rwl_name) |
Initialize a multi readers single writer lock identified by a name. | |
int | rt_named_rwl_delete (RWL *rwl) |
Delete a multi readers single writer lock in named mode. | |
SPL * | _rt_named_spl_init (unsigned long spl_name) |
Initialize a spinlock identified by a name. | |
int | rt_named_spl_delete (SPL *spl) |
Delete a spinlock in named mode. | |
int | set_rt_fun_entries (struct rt_native_fun_entry *entry) |
void | reset_rt_fun_entries (struct rt_native_fun_entry *entry) |
int | __rtai_sem_init (void) |
void | __rtai_sem_exit (void) |
Variables | |
rt_native_fun_entry | rt_sem_entries [] |
|
Definition at line 1755 of file sem.c. References reset_rt_fun_entries(), and rt_sem_entries. Here is the call graph for this function: ![]() |
|
Definition at line 1750 of file sem.c. References rt_sem_entries, and set_rt_fun_entries(). Here is the call graph for this function: ![]() |
|
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.
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.
References IS_RWL, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_rwl_delete(), rt_rwl_init(), and RWL. Here is the call graph for this function: ![]() |
|
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.
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.
References IS_SPL, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_spl_delete(), rt_spl_init(), and SPL. Here is the call graph for this function: ![]() |
|
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.
See rt_typed_sem_init for further clues. 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.
References IS_SEM, rt_free(), rt_get_adr_cnt(), rt_malloc(), rt_register(), rt_sem_delete(), rt_typed_sem_init(), and SEM. Here is the call graph for this function: ![]() |
|
|
|
|
Definition at line 736 of file sem.c. References dequeue_blocked(), RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, rt_schedule(), RT_TASK, SEM, and task. Referenced by rt_cond_wait(), and rt_cond_wait_until(). Here is the call graph for this function: ![]() |
|
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.
References CND, dequeue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, RT_TASK, SEM_ERR, 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.
References CND, enqueue_blocked(), flags, rt_cndmtx_signal(), RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, rt_sem_wait(), RT_TASK, SEM, and SEM_ERR. 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.
References CND, rt_cond_wait_until(), RTIME, and SEM. 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.
References CND, dequeue_blocked(), enqueue_blocked(), flags, rt_cndmtx_signal(), RT_SCHED_DELAYED, RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, rt_sem_wait(), RTIME, SEM, SEM_ERR, and SEM_TIMOUT. Referenced by _mq_timedreceive(), _mq_timedsend(), and rt_cond_wait_timed(). Here is the call graph for this function: ![]() |
|
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().
References rt_drg_on_adr_cnt(), rt_free(), rt_rwl_delete(), RWL, and SEM_ERR. Here is the call graph for this function: ![]() |
|
Delete a semaphore initialized in named mode. rt_named_sem_delete deletes a semaphore previously created with _rt_typed_named_sem_init().
References rt_drg_on_adr_cnt(), rt_free(), rt_sem_delete(), SEM, and SEM_ERR. Referenced by RT_named_sem_delete(). Here is the call graph for this function: ![]() |
|
Delete a spinlock in named mode. rt_named_spl_delete deletes a spinlock previously created with _rt_named_spl_init().
References rt_drg_on_adr_cnt(), rt_free(), rt_spl_delete(), and SPL. Here is the call graph for this function: ![]() |
|
destroys a multi readers single writer lock. rt_rwl_init destroys a multi readers single writer lock rwl.
References rt_sem_delete(), RWL, and SEM_ERR. Referenced by _rt_named_rwl_init(), and rt_named_rwl_delete(). Here is the call graph for this function: ![]() |
|
Initialize a multi readers single writer lock. rt_rwl_init initializes a multi readers single writer lock rwl.
References CNT_SEM, RES_SEM, rt_typed_sem_init(), and RWL. Referenced by _rt_named_rwl_init(). Here is the call graph for this function: ![]() |
|
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.
References flags, rt_sem_wait(), RT_TASK, RWL, SEM_ERR, and SEM_TIMOUT. Here is the call graph for this function: ![]() |
|
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.
|
|
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.
References rt_rwl_rdlock_until(), RTIME, and RWL. 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.
References flags, rt_sem_wait_until(), RT_TASK, RTIME, RWL, SEM_ERR, and SEM_TIMOUT. Referenced by rt_rwl_rdlock_timed(). Here is the call graph for this function: ![]() |
|
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.
References flags, rt_sem_signal(), RT_TASK, and RWL. Here is the call graph for this function: ![]() |
|
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.
References flags, rt_sem_wait(), RWL, and SEM_TIMOUT. Here is the call graph for this function: ![]() |
|
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.
References flags, rt_sem_wait_if(), and RWL. 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.
References rt_rwl_wrlock_until(), RTIME, and RWL. 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.
References flags, rt_sem_wait_until(), RTIME, RWL, and SEM_TIMOUT. Referenced by rt_rwl_wrlock_timed(). Here is the call graph for this function: ![]() |
|
Signaling a semaphore. 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.
References dequeue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, RT_TASK, SEM, SEM_ERR, and task. Referenced by RT_sem_broadcast(), and rt_sem_wait_barrier(). Here is the call graph for this function: ![]() |
|
Definition at line 232 of file sem.c. References SEM. |
|
Delete a semaphore. rt_sem_delete deletes a semaphore previously created with rt_sem_init().
References flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SCHED_SUSPENDED, rt_schedule(), RT_SEM_MAGIC, RT_TASK, rt_task_delete(), SEM, SEM_ERR, and task. Referenced by __rtai_netrpc_exit(), _rt_typed_named_sem_init(), rt_mbx_delete(), rt_msgq_delete(), rt_named_sem_delete(), and rt_rwl_delete(). Here is the call graph for this function: ![]() |
|
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.
References CNT_SEM, rt_typed_sem_init(), and SEM. Here is the call graph for this function: ![]() |
|
Signaling a semaphore. 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.
References cpuid, dequeue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_READY, RT_SCHED_SEMAPHORE, RT_SCHED_SUSPENDED, rt_schedule(), RT_SEM_MAGIC, RT_TASK, rt_task_delete(), SEM, SEM_ERR, and task. Referenced by _broadcast(), _receive(), _rt_mbx_ovrwr_send(), _rt_mbx_receive(), _rt_mbx_receive_if(), _rt_mbx_receive_until(), _rt_mbx_receive_wp(), _rt_mbx_send(), _rt_mbx_send_if(), _rt_mbx_send_until(), _rt_mbx_send_wp(), _rt_msg_broadcast(), _rt_msg_broadcast_if(), _rt_msg_broadcast_until(), _rt_msg_receive(), _rt_msg_receive_if(), _rt_msg_receive_until(), _rt_msg_send(), _rt_msg_send_if(), _rt_msg_send_until(), _send(), mbx_send_if(), net_resume_task(), rt_rwl_unlock(), RT_sem_signal(), and timer_fun(). Here is the call graph for this function: ![]() |
|
Take a semaphore. 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:
References count, enqueue_blocked(), flags, RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, RT_TASK, SEM, and SEM_ERR. Referenced by _rt_mbx_receive(), _rt_mbx_send(), _rt_msg_broadcast(), _rt_msg_receive(), _rt_msg_send(), hard_stub_fun(), rt_cond_wait(), rt_cond_wait_until(), rt_net_rpc(), rt_rwl_rdlock(), rt_rwl_wrlock(), RT_sem_wait(), rt_sem_wait_barrier(), and rt_send_req_rel_port(). Here is the call graph for this function: ![]() |
|
Wait on a semaphore barrier. 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.
References flags, rt_sem_broadcast(), RT_SEM_MAGIC, rt_sem_wait(), SEM, and SEM_ERR. Referenced by _broadcast(), and _receive(). Here is the call graph for this function: ![]() |
|
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.
References count, flags, RT_SEM_MAGIC, SEM, and SEM_ERR. Referenced by _rt_msg_broadcast_if(), _rt_msg_receive_if(), _rt_msg_send_if(), rt_net_rpc(), rt_rwl_wrlock_if(), and RT_sem_wait_if(). |
|
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.
References rt_sem_wait_until(), RTIME, and SEM. Referenced by RT_sem_wait_timed(). 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.
References count, dequeue_blocked(), enqueue_blocked(), flags, RT_SCHED_DELAYED, RT_SCHED_SEMAPHORE, RT_SEM_MAGIC, RTIME, SEM, SEM_ERR, and SEM_TIMOUT. Referenced by _rt_mbx_receive_until(), _rt_mbx_send_until(), _rt_msg_broadcast_until(), _rt_msg_receive_until(), _rt_msg_send_until(), rt_rwl_rdlock_until(), rt_rwl_wrlock_until(), rt_sem_wait_timed(), and RT_sem_wait_until(). Here is the call graph for this function: ![]() |
|
Initialize a spinlock. rt_spl_delete destroies a spinlock spl.
References SPL. Referenced by _rt_named_spl_init(), and rt_named_spl_delete(). |
|
Initialize a spinlock. rt_spl_init initializes a spinlock spl.
References SPL. Referenced by _rt_named_spl_init(). |
|
Acquire a spinlock. rt_spl_lock acquires a spinlock spl.
References atomic_cmpxchg, flags, RT_TASK, rtai_save_flags_and_cli, and SPL. |
|
Acquire a spinlock without waiting. rt_spl_lock_if acquires a spinlock spl without waiting.
References atomic_cmpxchg, flags, RT_TASK, rtai_restore_flags, rtai_save_flags_and_cli, and SPL. |
|
Acquire a spinlock with timeout. rt_spl_lock_timed acquires a spinlock spl, but waiting spinning only for an allowed time.
References atomic_cmpxchg, flags, imuldiv(), locked, rdtsc, RT_TASK, rtai_restore_flags, rtai_save_flags_and_cli, RTIME, SPL, and tuned. Here is the call graph for this function: ![]() |
|
Release an owned spinlock. rt_spl_lock releases an owned spinlock spl.
References flags, RT_TASK, rtai_restore_flags, rtai_save_flags_and_cli, and SPL. |
|
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.
References FIFO_Q, RES_SEM, RT_SEM_MAGIC, and SEM. Referenced by __rtai_netrpc_init(), _broadcast(), _rt_typed_named_sem_init(), rt_msgq_init(), rt_rwl_init(), rt_sem_init(), and rt_typed_mbx_init(). |
|
|
Definition at line 1706 of file sem.c. Referenced by __rtai_sem_exit(), and __rtai_sem_init(). |