Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
Task/Thread Scheduling

Periodic/cyclic safety task creation with fixed priorities (ADR-001). More...

Files

file  src/oal/task/sapi_task.c
 Task service: validates parameters, then dispatches to the backend registered via sapi_task_register_backend() (ADR-005).

Data Structures

struct  sapi_task_config_t
 Configuration for sapi_task_create(). More...

Typedefs

typedef struct sapi_task_impl_s * sapi_task_handle_t
 Opaque handle to a created task, returned by sapi_task_create().
typedef void(*) sapi_task_entry_t(void *user_ctx)
 Task entry point, invoked cyclically at the configured period.

Functions

 SAFEAPI_DECLARE_STORAGE (sapi_task_storage_t, 128U)
 Caller-owned, fixed-size storage backing one sapi_task_handle_t.
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.
sapi_status_t sapi_task_start (sapi_task_handle_t handle)
 Starts a created task.
sapi_status_t sapi_task_suspend (sapi_task_handle_t handle)
 Suspends a running task.
sapi_status_t sapi_task_destroy (sapi_task_handle_t handle)
 Terminates and destroys a task.

Detailed Description

Periodic/cyclic safety task creation with fixed priorities (ADR-001).

Typedef Documentation

◆ sapi_task_handle_t

typedef struct sapi_task_impl_s* sapi_task_handle_t

Opaque handle to a created task, returned by sapi_task_create().

Definition at line 32 of file sapi_task.h.

◆ sapi_task_entry_t

typedef void(*) sapi_task_entry_t(void *user_ctx)

Task entry point, invoked cyclically at the configured period.

Definition at line 35 of file sapi_task.h.

Function Documentation

◆ sapi_task_create()

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.

Parameters
storageCaller-owned storage for the handle's state. Must not be NULL.
configTask configuration. Must not be NULL; config->entry must not be NULL.
out_handleReceives the created task's handle. Must not be NULL.
Returns
SAPI_STATUS_OK; SAPI_STATUS_INVALID_PARAM for a bad argument; SAPI_STATUS_NOT_INITIALIZED if no backend is registered (sapi_task_register_backend()); SAPI_STATUS_NOT_SUPPORTED if the registered backend does not implement create. REQ-OAL-TASK-010

Definition at line 44 of file sapi_task.c.

◆ sapi_task_start()

sapi_status_t sapi_task_start ( sapi_task_handle_t handle)

Starts a created task.

Parameters
handleTask handle. Must not be NULL.
Returns
SAPI_STATUS_OK, SAPI_STATUS_INVALID_PARAM, SAPI_STATUS_NOT_INITIALIZED, or SAPI_STATUS_NOT_SUPPORTED (see sapi_task_create()). REQ-OAL-TASK-011

Definition at line 68 of file sapi_task.c.

◆ sapi_task_suspend()

sapi_status_t sapi_task_suspend ( sapi_task_handle_t handle)

Suspends a running task.

Parameters
handleTask handle. Must not be NULL.
Returns
See sapi_task_start(). REQ-OAL-TASK-012

Definition at line 85 of file sapi_task.c.

◆ sapi_task_destroy()

sapi_status_t sapi_task_destroy ( sapi_task_handle_t handle)

Terminates and destroys a task.

Parameters
handleTask handle. Must not be NULL. Invalid to use after this call.
Returns
See sapi_task_start(). REQ-OAL-TASK-013

Definition at line 102 of file sapi_task.c.