Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_task.c
Go to the documentation of this file.
1
7
#include "
rte/oal/task/rte_task.h
"
8
#include "
rte/utils/lifecycle/rte_lifecycle.h
"
9
#include "
rte_osadapter/task/rte_osadapter_task.h
"
10
12
14
17
static
const
rte_osadapter_task_t
*
s_osadapter
= NULL;
18
20
22
23
25
rte_status_t
rte_osadapter_task_register
(
const
rte_osadapter_task_t
*osadapter)
26
{
27
rte_status_t
lifecycle_status;
28
29
if
(osadapter == NULL)
30
{
31
return
RTE_STATUS_INVALID_PARAM
;
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
44
rte_status_t
rte_task_create
(rte_task_storage_t *storage,
45
const
rte_task_config_t
*config,
46
rte_task_handle_t
*out_handle)
47
{
48
if
((storage == NULL) || (config == NULL) || (out_handle == NULL))
49
{
50
return
RTE_STATUS_INVALID_PARAM
;
51
}
52
if
(config->
entry
== NULL)
53
{
54
return
RTE_STATUS_INVALID_PARAM
;
55
}
56
*out_handle = NULL;
57
/* REQ-LIFECYCLE-001/003 (ADR-026, OSA rules): setup-only - refused and reported once the setup phase is locked. */
58
{
59
rte_status_t
lifecycle_status =
rte_lifecycle_check_setup_allowed
();
60
61
if
(lifecycle_status !=
RTE_STATUS_OK
)
62
{
63
return
lifecycle_status;
64
}
65
}
66
if
(
s_osadapter
== NULL)
67
{
68
return
RTE_STATUS_NOT_INITIALIZED
;
69
}
70
if
(
s_osadapter
->create == NULL)
71
{
72
return
RTE_STATUS_NOT_SUPPORTED
;
73
}
74
return
s_osadapter
->create(storage, config, out_handle);
75
}
76
77
rte_status_t
rte_task_start
(
rte_task_handle_t
handle)
78
{
79
if
(handle == NULL)
80
{
81
return
RTE_STATUS_INVALID_PARAM
;
82
}
83
/* REQ-LIFECYCLE-001/003 (ADR-026, OSA rules): setup-only - refused and reported once the setup phase is locked. */
84
{
85
rte_status_t
lifecycle_status =
rte_lifecycle_check_setup_allowed
();
86
87
if
(lifecycle_status !=
RTE_STATUS_OK
)
88
{
89
return
lifecycle_status;
90
}
91
}
92
if
(
s_osadapter
== NULL)
93
{
94
return
RTE_STATUS_NOT_INITIALIZED
;
95
}
96
if
(
s_osadapter
->start == NULL)
97
{
98
return
RTE_STATUS_NOT_SUPPORTED
;
99
}
100
return
s_osadapter
->start(handle);
101
}
102
103
rte_status_t
rte_task_suspend
(
rte_task_handle_t
handle)
104
{
105
if
(handle == NULL)
106
{
107
return
RTE_STATUS_INVALID_PARAM
;
108
}
109
if
(
s_osadapter
== NULL)
110
{
111
return
RTE_STATUS_NOT_INITIALIZED
;
112
}
113
if
(
s_osadapter
->suspend == NULL)
114
{
115
return
RTE_STATUS_NOT_SUPPORTED
;
116
}
117
return
s_osadapter
->suspend(handle);
118
}
119
120
rte_status_t
rte_task_destroy
(
rte_task_handle_t
handle)
121
{
122
if
(handle == NULL)
123
{
124
return
RTE_STATUS_INVALID_PARAM
;
125
}
126
if
(
s_osadapter
== NULL)
127
{
128
return
RTE_STATUS_NOT_INITIALIZED
;
129
}
130
if
(
s_osadapter
->destroy == NULL)
131
{
132
return
RTE_STATUS_NOT_SUPPORTED
;
133
}
134
return
s_osadapter
->destroy(handle);
135
}
rte_lifecycle_check_setup_allowed
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 ...
Definition
rte_lifecycle.c:41
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
RTE_STATUS_OK
@ RTE_STATUS_OK
Definition
rte_status.h:28
RTE_STATUS_INVALID_PARAM
@ RTE_STATUS_INVALID_PARAM
Definition
rte_status.h:29
RTE_STATUS_NOT_SUPPORTED
@ RTE_STATUS_NOT_SUPPORTED
Definition
rte_status.h:34
RTE_STATUS_NOT_INITIALIZED
@ RTE_STATUS_NOT_INITIALIZED
Definition
rte_status.h:30
rte_task_suspend
rte_status_t rte_task_suspend(rte_task_handle_t handle)
Suspends a running task.
Definition
rte_task.c:103
rte_task_handle_t
struct rte_task_impl_s * rte_task_handle_t
Opaque handle to a created task, returned by rte_task_create().
Definition
rte_task.h:32
rte_task_create
rte_status_t rte_task_create(rte_task_storage_t *storage, const rte_task_config_t *config, rte_task_handle_t *out_handle)
Creates a task in the suspended state.
Definition
rte_task.c:44
rte_task_start
rte_status_t rte_task_start(rte_task_handle_t handle)
Starts a created task.
Definition
rte_task.c:77
rte_task_destroy
rte_status_t rte_task_destroy(rte_task_handle_t handle)
Terminates and destroys a task.
Definition
rte_task.c:120
s_osadapter
static const rte_osadapter_clocksync_t * s_osadapter
Definition
rte_clocksync.c:18
rte_lifecycle.h
Process-wide application setup-phase lock (ADR-026).
rte_osadapter_task.h
OSAdapter interface for task and thread scheduling.
rte_osadapter_task_register
rte_status_t rte_osadapter_task_register(const rte_osadapter_task_t *adapter)
Registers the OSAdapter task implementation.
Definition
rte_task.c:25
rte_task.h
OS Abstraction Layer - Task/thread scheduling service.
rte_osadapter_task_t
OSAdapter task scheduling operations vtable.
Definition
rte_osadapter_task.h:21
rte_task_config_t
Configuration for rte_task_create().
Definition
rte_task.h:39
rte_task_config_t::entry
rte_task_entry_t entry
Definition
rte_task.h:41
src
oal
task
rte_task.c
Generated by
1.18.0