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
Application Setup-Phase Lock

Process-wide INIT/RUN boundary enforcement (ADR-026). More...

Files

file  src/utils/lifecycle/rte_lifecycle.c
 Implementation of the process-wide application setup-phase lock - see rte_lifecycle.h.

Functions

void rte_lifecycle_lock (void)
 Locks the application's setup phase.
void rte_lifecycle_unlock (void)
 Unlocks the application's setup phase (setup is allowed again).
bool rte_lifecycle_is_locked (void)
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 that creates/registers a new long-lived resource (a timer, channel, voter, cross-comparator, or watchdog - see this file's own header for the excluded netlink/dual exceptions).

Detailed Description

Process-wide INIT/RUN boundary enforcement (ADR-026).

Function Documentation

◆ rte_lifecycle_lock()

void rte_lifecycle_lock ( void )

Locks the application's setup phase.

After this call, rte_lifecycle_check_setup_allowed() (and therefore every setup-only constructor that calls it) returns RTE_STATUS_INVALID_STATE until the next rte_lifecycle_unlock(). Idempotent: locking an already-locked application is a no-op.

Intended caller: rte_appmanager_run(), immediately after ops->init() returns RTE_STATUS_OK - integrator application code does not call this directly under normal use.

Global variables declarations Local function declarations Global functions

Definition at line 26 of file rte_lifecycle.c.

◆ rte_lifecycle_unlock()

void rte_lifecycle_unlock ( void )

Unlocks the application's setup phase (setup is allowed again).

Idempotent: unlocking an already-unlocked application is a no-op.

Intended caller: rte_appmanager_run(), at the start of every call - this is what lets this framework's own test suite (and any integrator code) call rte_appmanager_run() more than once, sequentially, in one process and have each call's own setup phase behave independently.

Definition at line 31 of file rte_lifecycle.c.

◆ rte_lifecycle_is_locked()

bool rte_lifecycle_is_locked ( void )
Returns
true if the application's setup phase is currently locked (see rte_lifecycle_lock()), false otherwise. Intended for diagnostics; prefer rte_lifecycle_check_setup_allowed() at an actual constructor's own call site.

Definition at line 36 of file rte_lifecycle.c.

◆ 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 that creates/registers a new long-lived resource (a timer, channel, voter, cross-comparator, or watchdog - see this file's own header for the excluded netlink/dual exceptions).

Returns
RTE_STATUS_INVALID_STATE if the application's setup phase is currently locked (after reporting it, REQ-LIFECYCLE-003); RTE_STATUS_OK otherwise.

Definition at line 41 of file rte_lifecycle.c.