Expand description
§Tracing
The trace feature enables a number of callbacks that can be used to track the
lifecycle of tasks and/or executors.
The passed IDs are only guaranteed to be unique for the duration of time the item is valid. If a task ends, and is re-spawned, it MAY or MAY NOT have the same ID. While a task is active, the id will not change. For executors, the same applies, but the IDs will be stable for practical embedded programs.
Callbacks can be used by enabling the trace feature, implementing the Trace
trait, and registering the implementation with the trace_impl! macro.
All callbacks must be implemented.
§Task Tracing lifecycle
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
│(1) │
│ │
╔════▼════╗ (2) ┌─────────┐ (3) ┌─────────┐ │
│ ║ SPAWNED ║────▶│ WAITING │────▶│ RUNNING │
╚═════════╝ └─────────┘ └─────────┘ │
│ ▲ ▲ │ │ │
│ (4) │ │(6) │
│ │(7) └ ─ ─ ┘ │ │
│ │ │ │
│ ┌──────┐ (5) │ │ ┌─────┐
│ IDLE │◀────────────────┘ └─▶│ END │ │
│ └──────┘ └─────┘
┌──────────────────────┐ │
└ ┤ Task Trace Lifecycle │─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
└──────────────────────┘- A task is spawned,
task_newis called - A task is enqueued for the first time,
task_ready_beginis called - A task is polled,
task_exec_beginis called - WHILE a task is polled, the task is re-awoken, and
task_ready_beginis called. The task does not IMMEDIATELY move state, until polling is complete and the RUNNING state is exited.task_exec_endis called when polling is complete, marking the transition to WAITING - Polling is complete,
task_exec_endis called - The task has completed, and
task_endis called - A task is awoken,
task_ready_beginis called
§Executor Tracing lifecycle
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
│(1) │
│ │
╔═══▼══╗ (2) ┌────────────┐ (3) ┌─────────┐ │
│ ║ IDLE ║──────────▶│ SCHEDULING │──────▶│ POLLING │
╚══════╝ └────────────┘ └─────────┘ │
│ ▲ │ ▲ │
│ (5) │ │ (4) │ │
│ └──────────────┘ └────────────┘
┌──────────────────────────┐ │
└ ┤ Executor Trace Lifecycle │─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
└──────────────────────────┘- The executor is started (no associated trace)
- A task on this executor is awoken.
task_ready_beginis called when this occurs, andpoll_startis called when the executor actually begins running - The executor has decided a task to poll.
task_exec_beginis called - The executor finishes polling the task.
task_exec_endis called - The executor has finished polling tasks.
executor_idleis called
§Idle
executor_idle only means that a single executor has run out of work. With
multiple executors (e.g. a thread-mode executor plus one or more interrupt
executors), an interrupt executor going idle returns to the preempted
lower-priority context, which keeps running. The current thread/core is only
idle when its thread-mode executor reaches its sleep site, at which point
idle is called. In multi-core chips, or when using threads under std or an
RTOS, this does not mean the entire system is idle.
Traits§
- Trace
- Executor trace hooks.