feat(task/interrupt): Allow runtime changes to task priority/core_id. Expose interrupt task methods for runtime control#653
Merged
Conversation
… Expose interrupt task methods for runtime control
|
✅Static analysis result - no issues found! ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an API to reconfigure an
espp::Task's FreeRTOS priority and core affinity at runtime, and exposes the same control (plus task start/stop) onespp::Interrupt, which owns and starts its handler task in its constructor.espp::Task:bool set_priority(size_t priority)— stores the new priority (used on the nextstart()) and, if the task is running, applies it immediately viavTaskPrioritySet(). Clamps toconfigMAX_PRIORITIES - 1. Returnstrueif applied to the live task.bool set_core_id(int core_id)— stores the new core id (used on the nextstart()). On the default ESP-IDF FreeRTOS port a running task's core affinity is fixed at creation, so it is applied on the nextstart(); if the build provides the SMPvTaskCoreAffinitySetAPI (configUSE_CORE_AFFINITYon a multi-core SMP build) the change is applied live. Returnstrueif applied to the live task.Both setters always persist the value for the next start regardless of the return value, and the return value honestly reports whether the change hit the already-running task.
espp::Interrupt:bool set_task_priority(size_t)/bool set_task_core_id(int)— forward to the underlying handlerTask.bool start_task()/bool stop_task()— forward toTask::start()/Task::stop(). Since the handler task is created in the constructor, these let callers restart it so a new core id fromset_task_core_id()takes effect.stop_task()'s docs note that ISRs keep enqueueing while the task is stopped, so events are serviced on restart (not dropped) until the queue fills.Motivation and Context
The BSP components recently gained Kconfig options for their
espp::Interrupttask priority / core id, but those are compile-time only and global. This was raised as a follow-up: provide a programmatic/API way to set these values. Because every BSP already exposesinterrupts(), this change makes the interrupt task's priority and core configurable at runtime on all of them with no per-BSP changes, e.g.:Kconfig remains the zero-config default; the new API is an optional runtime override on top of it.
How has this been tested?
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Task example
Types of changes
Checklist:
Software