Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_task.c
Go to the documentation of this file.
1
10
12
14
17static const sapi_task_backend_t *s_backend = NULL;
18
20
22
23
26{
27 sapi_status_t lifecycle_status;
28
29 if (backend == NULL)
30 {
32 }
33 /* REQ-LIFECYCLE-001 (ADR-026): registering a backend is a setup-only
34 * action - refuse once the application's setup phase has been locked. */
35 lifecycle_status = sapi_lifecycle_check_setup_allowed();
36 if (lifecycle_status != SAPI_STATUS_OK)
37 {
38 return lifecycle_status;
39 }
40 s_backend = backend;
41 return SAPI_STATUS_OK;
42}
43
44sapi_status_t sapi_task_create(sapi_task_storage_t *storage,
45 const sapi_task_config_t *config,
46 sapi_task_handle_t *out_handle)
47{
48 if ((storage == NULL) || (config == NULL) || (out_handle == NULL))
49 {
51 }
52 if (config->entry == NULL)
53 {
55 }
56 *out_handle = NULL;
57 if (s_backend == NULL)
58 {
60 }
61 if (s_backend->create == NULL)
62 {
64 }
65 return s_backend->create(storage, config, out_handle);
66}
67
69{
70 if (handle == NULL)
71 {
73 }
74 if (s_backend == NULL)
75 {
77 }
78 if (s_backend->start == NULL)
79 {
81 }
82 return s_backend->start(handle);
83}
84
86{
87 if (handle == NULL)
88 {
90 }
91 if (s_backend == NULL)
92 {
94 }
95 if (s_backend->suspend == NULL)
96 {
98 }
99 return s_backend->suspend(handle);
100}
101
103{
104 if (handle == NULL)
105 {
107 }
108 if (s_backend == NULL)
109 {
111 }
112 if (s_backend->destroy == NULL)
113 {
115 }
116 return s_backend->destroy(handle);
117}
sapi_status_t sapi_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
@ SAPI_STATUS_NOT_SUPPORTED
Definition sapi_status.h:34
@ SAPI_STATUS_INVALID_PARAM
Definition sapi_status.h:29
@ SAPI_STATUS_NOT_INITIALIZED
Definition sapi_status.h:30
@ SAPI_STATUS_OK
Definition sapi_status.h:28
sapi_status_t sapi_task_register_backend(const sapi_task_backend_t *backend)
Registers the backend implementation used by every sapi_task_* call (ADR-005 section 2....
Definition sapi_task.c:25
sapi_status_t sapi_task_create(sapi_task_storage_t *storage, const sapi_task_config_t *config, sapi_task_handle_t *out_handle)
Creates a task in the suspended state.
Definition sapi_task.c:44
sapi_status_t sapi_task_start(sapi_task_handle_t handle)
Starts a created task.
Definition sapi_task.c:68
struct sapi_task_impl_s * sapi_task_handle_t
Opaque handle to a created task, returned by sapi_task_create().
Definition sapi_task.h:32
sapi_status_t sapi_task_suspend(sapi_task_handle_t handle)
Suspends a running task.
Definition sapi_task.c:85
sapi_status_t sapi_task_destroy(sapi_task_handle_t handle)
Terminates and destroys a task.
Definition sapi_task.c:102
static const sapi_clocksync_backend_t * s_backend
Process-wide application setup-phase lock (ADR-026).
OS Abstraction Layer - Task/thread scheduling service.
OS-backend adaptation surface for the Task/thread scheduling service (ADR-005, ADR-021).
Backend vtable: an integrator's implementation of the task scheduling service for a specific OS/RTOS ...
sapi_status_t(*) suspend(sapi_task_handle_t handle)
Backend implementation of sapi_task_suspend(). May be NULL.
sapi_status_t(*) create(sapi_task_storage_t *storage, const sapi_task_config_t *config, sapi_task_handle_t *out_handle)
Backend implementation of sapi_task_create(). May be NULL.
sapi_status_t(*) destroy(sapi_task_handle_t handle)
Backend implementation of sapi_task_destroy(). May be NULL.
sapi_status_t(*) start(sapi_task_handle_t handle)
Backend implementation of sapi_task_start(). May be NULL.
Configuration for sapi_task_create().
Definition sapi_task.h:39
sapi_task_entry_t entry
Definition sapi_task.h:41