Skip to content
Back to skills

Kernel Services

ASecurity

Advanced Zephyr RTOS kernel services. Covers inter-thread communication using Zbus (pub/sub), behavioral management with the State Machine Framework (SMF), background processing via work queues, and persistent configuration with the Settings subsystem. Trigger when building modular application architectures, complex state-driven logic, or requiring persistent data storage.

  • 63 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 1, 2026
ai-agentsbackend

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 1, 2026

npx -y skills add beriberikix/zephyr-agent-skills --skill kernel-services --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kernel Services?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kernel Services
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/beriberikix-kernel-services/badge)](https://www.skillsdirectory.com/skills/beriberikix-kernel-services)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: kernel-services
description: Advanced Zephyr RTOS kernel services. Covers inter-thread communication using Zbus (pub/sub), behavioral management with the State Machine Framework (SMF), background processing via work queues, and persistent configuration with the Settings subsystem. Trigger when building modular application architectures, complex state-driven logic, or requiring persistent data storage.
---

# Zephyr Kernel Services

Move beyond basic threading and logging to build modular, event-driven, and robust Zephyr applications.

## Core Workflows

### 1. Event-Driven Communication (Zbus)
Decouple your modules using a lightweight publish-and-subscribe bus.
- **Reference**: **[zbus.md](references/zbus.md)**
- **Key Tools**: `ZBUS_CHAN_DEFINE`, `ZBUS_SUBSCRIBER_DEFINE`, `zbus_chan_pub`.

### 2. Behavioral Logic (SMF)
Manage complex system states and transitions using the State Machine Framework.
- **Reference**: **[smf.md](references/smf.md)**
- **Key Tools**: `smf_set_state`, `SMF_CREATE_STATE`, Hierarchical states.

### 3. Background Processing (Work Queues)
Defer long-running or non-critical tasks to prevent blocking interrupts or high-priority threads.
- **Reference**: **[settings_workqueue.md](references/settings_workqueue.md)**
- **Key Tools**: `k_work_submit`, `k_work_delayable`, Custom work queues.

### 4. Persistence (Settings)
Save and restore configuration data and state across reboots.
- **Reference**: **[settings_workqueue.md](references/settings_workqueue.md#settings-subsystem)**
- **Key Tools**: `settings_load`, `settings_save_one`, NVS backends.

## Quick Start (Zbus)
```c
// Define a channel for sensor data
ZBUS_CHAN_DEFINE(sensor_data_chan, struct sensor_msg, NULL, NULL, ZBUS_OBSERVERS_EMPTY, ZBUS_CHAN_DEFAULTS);

// Publish from a thread
zbus_chan_pub(&sensor_data_chan, &msg, K_NO_WAIT);
```

## Professional Patterns (Asset Tracker Style)
- **Modularity**: Use Zbus as the backbone for inter-module communication.
- **Predictability**: Use SMF to define clear lifecycle states for each module (e.g., Uninitialized -> Ready -> Active -> Error).
- **Responsiveness**: Use custom work queues for sensor data ingestion to keep the main thread responsive for cloud communication.
- **Sensor Integration**: For sensor data ingestion patterns, see the **[hardware-io](../hardware-io/SKILL.md)** skill.

## Automation Tools
- **[zbus_channel_lint.py](scripts/zbus_channel_lint.py)**: Detect duplicate `ZBUS_CHAN_DEFINE` names across source files.

## Examples & Templates
- **[smf_state_table_template.c](assets/smf_state_table_template.c)**: Starter SMF state table and lifecycle wiring.

## Validation Checklist
- [ ] Zbus publishers and subscribers exchange messages without deadlock or missed updates.
- [ ] SMF transitions follow expected state graph under normal and error conditions.
- [ ] Deferred work executes on intended queue context with bounded execution time.
- [ ] Settings values persist across reboot and reload successfully at startup.

## Resources

- **[References](references/)**:
  - `zbus.md`: Publish/Subscribe patterns and subscriber types.
  - `smf.md`: Finite and Hierarchical state machine implementation.
  - `settings_workqueue.md`: Background work and persistent storage.
- **[Scripts](scripts/)**:
  - `zbus_channel_lint.py`: Zbus channel name collision checker.
- **[Assets](assets/)**:
  - `smf_state_table_template.c`: State-machine template.

Files in this skill

  • SKILL.md3.4 KB
  • assets/smf_state_table_template.c1.4 KB
  • references/settings_workqueue.md2 KB
  • references/smf.md2.2 KB
  • references/zbus.md2.6 KB
  • scripts/zbus_channel_lint.py2.1 KB
  • skill-meta.yaml522 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.