Typedefs | |
typedef __peak_task_lock * | peak_task_lock |
Opaque task lock type. | |
typedef __peak_task_mutex * | peak_task_mutex |
Opaque task mutex type. | |
Functions | |
void | peak_task_exclusivity (void) |
Acquire task execution exclusivity. | |
peak_task_lock | peak_task_lock_create (peak_task task) |
Create a task's lock. | |
void | peak_task_lock_acquire (peak_task_lock lock) |
Acquire a task's lock. | |
int | peak_task_lock_try (peak_task_lock lock) |
Try to acquire a task's lock. | |
void | peak_task_lock_release (peak_task_lock lock) |
Release a task's lock. | |
void | peak_task_lock_handoff (peak_task_lock lock) |
Hand-off a task's lock. | |
peak_task_mutex | peak_task_mutex_create (peak_task task) |
Create a task's mutex. | |
void | peak_task_mutex_lock (peak_task_mutex mutex) |
Lock a task's mutex. | |
void | peak_task_mutex_trylock (peak_task_mutex mutex) |
Try to lock a task's mutex. | |
void | peak_task_mutex_unlock (peak_task_mutex mutex) |
Unlock a task's mutex. |
|
Acquire task execution exclusivity.
This function acquires temporary exclusive task execution among all task's threads. It's usually called at the beginning of an event-callback to avoid conflicts with other events (as they might be processed in parallel), when you deal with a lot of shared data in the callback. |
|
Acquire a task's lock.
This function acquires a task's lock. If the lock is already owned by another thread of the task, then the calling thread will block. However, this function does nothing if the task has only one thread. If a deadlock is detected, the program will abort, so be careful with recursions! Possibly, use peak_task_lock_try(). |
|
Create a task's lock. Allow you to lock threads in order to create critical regions, for example, within a task, with peak_task_lock_acquire(), peak_task_lock_release(), etc. Like other PEAK's objets, you can destroy a lock with peak_release(). THEY ARE ACTIVE LOCKS FOR SMALL DATA STRUCTURES PROTECTION ONLY. If you think you will have almost no collision for a critical region, they are for you.
|
|
Hand-off a task's lock.
To assume the lock's ownership, this function passes a task's lock from the calling thread to another thread of the task. The lock must be already owned by the calling thread. If no other thread is waiting for acquiring the lock, this call will block until it happens. If the task has only one running thread, this function will abort the program (because if you use this function, you want a special synchronization behaviour that can't happen with one thread only). See peak_task_set_info() to properly configure your task. |
|
Release a task's lock.
This function releases a task's lock, so one another thread of the task can acquire it. However, this function does nothing if the task has only one thread. |
|
Try to acquire a task's lock.
This function attempts to acquire a task's lock without blocking. The return value indicatees whether the lock was acquired. This function does nothing if the task has only one running thread and in that case always succeeds.
|
|
Create a task's mutex. Allow you to create critical regions within a task, with peak_task_mutex_lock(), peak_task_mutex_unlock(), etc. Like other PEAK's objets, you can destroy a mutex with peak_release(). Task's mutex are more suitable to create large mutual exclusion regions than task's locks are, as they shouldn't spinlock much. However, if you need to protect basic and small data structures, it might be lighter to use task's locks (eg. for a simple operation like "object->i++;" ).
|
|
Lock a task's mutex.
This function locks a task's mutex. If the mutex is already locked then the calling thread will block until the mutex becomes available. However, this function does nothing if the task has only one thread. If a deadlock is detected, the program will abort. Possibly, use peak_task_mutex_trylock(). |
|
Try to lock a task's mutex.
This function locks a task's mutex. If the mutex is already locked then the calling thread will block until the mutex becomes available. However, this function does nothing if the task has only one thread. |
|
Unlock a task's mutex.
This function unlocks a task's mutex. However, this function does nothing if the task has only one thread. |