Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_mutex.c
Go to the documentation of this file.
1
10
12
14
18
20
22
23
26{
27 rte_status_t lifecycle_status;
28
29 if (osadapter == NULL)
30 {
32 }
33 /* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
34 * action - refuse once the application's setup phase has been locked. */
35 lifecycle_status = rte_lifecycle_check_setup_allowed();
36 if (lifecycle_status != RTE_STATUS_OK)
37 {
38 return lifecycle_status;
39 }
40 s_osadapter = osadapter;
41 return RTE_STATUS_OK;
42}
43
44rte_status_t rte_mutex_create(rte_mutex_storage_t *storage, rte_mutex_handle_t *out_handle)
45{
46 if ((storage == NULL) || (out_handle == NULL))
47 {
49 }
50 *out_handle = NULL;
51 /* REQ-LIFECYCLE-001 (ADR-026): a mutex is a setup-only resource - refuse
52 * once the application's setup phase has been locked (rte_appmanager_run(),
53 * after ops->init() succeeds) - same posture as rte_timer_create()/
54 * rte_task_create(). */
55 {
57
58 if (lifecycle_status != RTE_STATUS_OK)
59 {
60 return lifecycle_status;
61 }
62 }
63 if (s_osadapter == NULL)
64 {
66 }
67 if (s_osadapter->create == NULL)
68 {
70 }
71 return s_osadapter->create(storage, out_handle);
72}
73
75{
76 if (handle == NULL)
77 {
79 }
80 if (s_osadapter == NULL)
81 {
83 }
84 if (s_osadapter->lock == NULL)
85 {
87 }
88 return s_osadapter->lock(handle);
89}
90
92{
93 /* REQ-OAL-MUTEX-014: same checks as rte_mutex_lock(); not lifecycle-gated
94 * (an operational call). The timeout and the OSAdapter's result are
95 * passed through unchanged. */
96 if (handle == NULL)
97 {
99 }
100 if (s_osadapter == NULL)
101 {
103 }
104 if (s_osadapter->lock_timed == NULL)
105 {
107 }
108 return s_osadapter->lock_timed(handle, timeout_ms);
109}
110
112{
113 if (handle == NULL)
114 {
116 }
117 if (s_osadapter == NULL)
118 {
120 }
121 if (s_osadapter->unlock == NULL)
122 {
124 }
125 return s_osadapter->unlock(handle);
126}
127
129{
130 if (handle == NULL)
131 {
133 }
134 if (s_osadapter == NULL)
135 {
137 }
138 if (s_osadapter->destroy == NULL)
139 {
141 }
142 return s_osadapter->destroy(handle);
143}
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
rte_status_t rte_mutex_destroy(rte_mutex_handle_t handle)
Destroys a mutex, releasing any OSAdapter resources bound to it. Must not be called while any task ho...
Definition rte_mutex.c:128
rte_status_t rte_mutex_lock_timed(rte_mutex_handle_t handle, rte_duration_ms_t timeout_ms)
Waits at most timeout_ms for the mutex (OSA rule R2: every wait bounded).
Definition rte_mutex.c:91
rte_status_t rte_mutex_create(rte_mutex_storage_t *storage, rte_mutex_handle_t *out_handle)
Creates (and initializes, unlocked) a priority-inheritance mutex bound to caller-owned storage (REQ-O...
Definition rte_mutex.c:44
rte_status_t rte_mutex_unlock(rte_mutex_handle_t handle)
Releases a mutex previously locked by the calling task.
Definition rte_mutex.c:111
struct rte_mutex_impl_s * rte_mutex_handle_t
Definition rte_mutex.h:47
rte_status_t rte_mutex_lock(rte_mutex_handle_t handle)
Blocks the calling task until it holds the mutex.
Definition rte_mutex.c:74
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
uint32_t rte_duration_ms_t
Definition rte_types.h:27
static const rte_osadapter_clocksync_t * s_osadapter
Process-wide application setup-phase lock (ADR-026).
OS Abstraction Layer - Mutual exclusion service.
OSAdapter interface for mutual exclusion.
rte_status_t rte_osadapter_mutex_register(const rte_osadapter_mutex_t *adapter)
Registers the OSAdapter mutex implementation.
Definition rte_mutex.c:25
OSAdapter mutex operations vtable.