|
Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Non-recursive blocking mutual exclusion (ADR-033). More...
Files | |
| file | src/oal/mutex/sapi_mutex.c |
| Mutex service: validates parameters, then dispatches to the backend registered via sapi_mutex_register_backend() (ADR-033). | |
Typedefs | |
| typedef struct sapi_mutex_impl_s * | sapi_mutex_handle_t |
Functions | |
| SAFEAPI_DECLARE_STORAGE (sapi_mutex_storage_t, 128U) | |
| sapi_status_t | sapi_mutex_create (sapi_mutex_storage_t *storage, sapi_mutex_handle_t *out_handle) |
| Creates (and initializes, unlocked) a mutex bound to caller-owned storage. | |
| sapi_status_t | sapi_mutex_lock (sapi_mutex_handle_t handle) |
| Blocks the calling task until it holds the mutex. | |
| sapi_status_t | sapi_mutex_unlock (sapi_mutex_handle_t handle) |
| Releases a mutex previously locked by the calling task. | |
| sapi_status_t | sapi_mutex_destroy (sapi_mutex_handle_t handle) |
| Destroys a mutex, releasing any backend resources bound to it. Must not be called while any task holds or is waiting on the lock. | |
Non-recursive blocking mutual exclusion (ADR-033).
| typedef struct sapi_mutex_impl_s* sapi_mutex_handle_t |
Opaque handle bound to a sapi_mutex_storage_t after sapi_mutex_create().
Definition at line 44 of file sapi_mutex.h.
| SAFEAPI_DECLARE_STORAGE | ( | sapi_mutex_storage_t | , |
| 128U | ) |
Opaque caller-owned storage for one mutex instance. Size is part of the ABI.
| sapi_status_t sapi_mutex_create | ( | sapi_mutex_storage_t * | storage, |
| sapi_mutex_handle_t * | out_handle ) |
Creates (and initializes, unlocked) a mutex bound to caller-owned storage.
| storage | Caller-owned storage the mutex's state is placed into. Must not be NULL and must outlive the mutex. |
| out_handle | Receives the created mutex's handle. Must not be NULL. |
Definition at line 44 of file sapi_mutex.c.
| sapi_status_t sapi_mutex_lock | ( | sapi_mutex_handle_t | handle | ) |
Blocks the calling task until it holds the mutex.
| handle | Mutex to lock. Must not be NULL. |
Definition at line 74 of file sapi_mutex.c.
| sapi_status_t sapi_mutex_unlock | ( | sapi_mutex_handle_t | handle | ) |
Releases a mutex previously locked by the calling task.
| handle | Mutex to unlock. Must not be NULL. Unlocking a mutex the calling task does not hold is undefined behavior (same as pthread_mutex_unlock()). |
Definition at line 91 of file sapi_mutex.c.
| sapi_status_t sapi_mutex_destroy | ( | sapi_mutex_handle_t | handle | ) |
Destroys a mutex, releasing any backend resources bound to it. Must not be called while any task holds or is waiting on the lock.
| handle | Mutex to destroy. Must not be NULL. Invalid to use after this call. |
Definition at line 108 of file sapi_mutex.c.