Skip to content

[Core] Add CMSIS-RTOS2 threading backend - #748

Open
GwnDaan wants to merge 8 commits into
mainfrom
daan/cmsis2-thread-sync
Open

GwnDaan wants to merge 8 commits into
mainfrom
daan/cmsis2-thread-sync

Conversation

@GwnDaan

@GwnDaan GwnDaan commented Sep 29, 2026

Copy link
Copy Markdown
Member

Implements the threading intent of #319 and supersedes the approach in #458 on current main. The goal is to enable embedded RTOS platforms such as Zephyr and FreeRTOS without requiring standard-library threading support.

  • Adds CMSIS-RTOS2 as an alternative backend in the existing isobus threading abstraction.
  • Moves direct stack use of std::thread, mutexes, condition variables, sleep, and yield onto that abstraction where needed, including CAN, TC, and VT workers.
  • Preserves normal std-threaded and CAN_STACK_DISABLE_THREADS behavior. No namespace std changes.
  • Removes the old _gettimeofday requirement; current main provides TimeSource. Platform-specific CAN and time-source integration remain out of scope.

Draft: std and no-thread builds and existing tests pass, and the CMSIS code compiles against Arm and Zephyr CMSIS headers. Zephyr integration builds, hardware testing, and RTOS runtime testing are still pending.

@GwnDaan
GwnDaan added this pull request to stack #750 September 29, 2026 12:07
@GwnDaan
GwnDaan marked this pull request as ready for review September 29, 2026 16:07
@GwnDaan
GwnDaan requested review from ad3154 and martonmiklos and a balanced review from Copilot September 29, 2026 16:07
@GwnDaan GwnDaan self-assigned this Sep 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The disabled-thread backend currently fails compilation and skips VT parsing, while TC worker reinitialization can terminate the process.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds CMSIS-RTOS2 support to the shared threading abstraction and migrates core worker threads and synchronization primitives.

Changes:

  • Implements CMSIS mutex, thread, condition-variable, sleep, and yield wrappers.
  • Migrates CAN, VT, and TC workers to the abstraction.
  • Adds CMake backend selection and configuration validation.
File Description
CMakeLists.txt Adds CMSIS backend selection.
utility/​CMakeLists.txt Exposes the CMSIS definition.
utility/​include/​isobus/​utility/​thread_synchronization.hpp Implements threading backends.
isobus/​CMakeLists.txt Configures Isobus for CMSIS.
isobus/​src/​isobus_virtual_terminal_working_set_base.cpp Migrates working-set locks.
isobus/​src/​isobus_virtual_terminal_server_managed_working_set.cpp Migrates parser thread and locks.
isobus/​src/​isobus_virtual_terminal_client.cpp Migrates the VT worker thread.
isobus/​src/​isobus_task_controller_server.cpp Migrates server synchronization.
isobus/​src/​isobus_task_controller_client.cpp Migrates the TC worker thread.
isobus/​include/​isobus/​isobus/​isobus_virtual_terminal_working_set_base.hpp Uses abstract mutex type.
isobus/​include/​isobus/​isobus/​isobus_virtual_terminal_server_managed_working_set.hpp Uses abstract thread type.
isobus/​include/​isobus/​isobus/​isobus_virtual_terminal_client.hpp Uses owned abstract thread.
isobus/​include/​isobus/​isobus/​isobus_task_controller_server.hpp Exposes abstract synchronization types.
isobus/​include/​isobus/​isobus/​isobus_task_controller_client.hpp Uses owned abstract thread.
hardware_integration/​CMakeLists.txt Configures hardware integration for CMSIS.
hardware_integration/​src/​can_hardware_interface.cpp Migrates CAN worker synchronization.
hardware_integration/​include/​isobus/​hardware_integration/​can_hardware_interface.hpp Declares abstract CAN threading members.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread isobus/src/isobus_task_controller_client.cpp
Comment thread utility/include/isobus/utility/thread_synchronization.hpp
Comment thread utility/include/isobus/utility/thread_synchronization.hpp
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants