Kyron Foundation Component Architecture#

Kyron Foundation Component Architecture
status: draft
security: YES
safety: QM
version: 1
Kyron Foundation
status: valid
security: YES
safety: QM
bazel_target: @@//src/kyron-foundation:libkyron_foundation
bazel_type: rust_library
version: 1
coverage: lines 96% · branches 91% · files 14/21

Overview#

Kyron Foundation provides the containers, synchronisation and threading primitives that Kyron Runtime (comp__kyron_runtime) is built on. It has no own runtime behaviour: every function runs on the thread of its caller. It builds on the iceoryx2 building-block crates (iceoryx2_bb_*) for vectors, lock-free structures and memory allocation.

Static Architecture#

Kyron Foundation Static View
status: valid
security: YES
safety: QM
version: 1

The component is structured into the following parts.

Part

Responsibility

Containers (src/containers)

SpmcStealQueue (the local task queue of an async worker, with work stealing), MpmcQueue (the global task queue), TriggerQueue (a bounded queue with a blocking consumer, used by the safety worker and by every dedicated worker), GrowableVec, the intrusive linked list and the reusable object and vector pools.

Synchronisation (src/sync, src/cell)

Atomics and an UnsafeCell wrapper. Both switch to their Loom counterparts in Loom builds, so that the concurrency tests check every interleaving.

Threading (src/threading)

ThreadWaitBarrier: an execution engine waits until all its worker threads are ready.

Base and macros (src/base, src/macros)

A fast pseudo-random generator (the start index for work stealing) and not_recoverable_error!, which logs a broken invariant and panics. It does not abort by itself, so the panic can be caught on an application thread.

Prelude (src/prelude.rs)

Re-exports the iceoryx2 building blocks (the QNX 8 variants on QNX) and the logging macros.

Dynamic Architecture#

Task Queue Push, Overflow and Steal
status: valid
security: YES
safety: QM
version: 1

How the runtime uses the foundation task queues. Each async worker owns one SpmcStealQueue; the execution engine owns one MpmcQueue.

The runtime panics on Err(task) (queue overflow), see Task Life Cycle (comp_arc_dyn__kyron_runtime__task_lifecycle).

Interfaces#

Kyron Foundation API
status: valid
security: NO
safety: QM
language: rust
version: 1

The public Rust API of kyron-foundation: the containers, sync, cell, threading, base and macros modules and the prelude. Its main users are the Kyron components. Applications use CommonErrors directly: it is the error type of kyron::JoinResult and of the channel operations. The contract of each type and function is documented in its rustdoc. Operations are added together with the component requirements.