sched/mqueue: Enable receiving messages on an interrupt handler#18376
Merged
linguini1 merged 1 commit intoapache:masterfrom Feb 11, 2026
Merged
sched/mqueue: Enable receiving messages on an interrupt handler#18376linguini1 merged 1 commit intoapache:masterfrom
linguini1 merged 1 commit intoapache:masterfrom
Conversation
The internal implementation of `file_mq_receive` did not allow receiving a message from an interrupt handler. Although it is not possible to wait for a message in an interrupt context, it is perfectly possible to retrieve already-existing messages from the message queue. This commit modifies file_mq_timedreceive_internal to enable checking the message list and, if no messages exist, it returns immediately. This enables receiving any existing messages in an interrupt context. Signed-off-by: Tiago Medicci Serrano <tiago.medicci@espressif.com>
acassis
approved these changes
Feb 10, 2026
linguini1
approved these changes
Feb 11, 2026
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.
Summary
The internal implementation of
file_mq_receivedid not allow receiving a message from an interrupt handler. Although it is not possible to wait for a message in an interrupt context, it is perfectly possible to retrieve already-existing messages from the message queue. This commit modifies file_mq_timedreceive_internal to enable checking the message list and, if no messages exist, it returns immediately. This enables receiving any existing messages in an interrupt context.Impact
Impact on user: Yes. It allows receiving existing messages in an interrupt context.
Impact on build: No.
Impact on hardware: No.
Impact on documentation: No.
Impact on security: No.
Impact on compatibility: No.
Testing
It can be tested with a simple testing application available at tmedicci's nuttx-apps (branch
test/mqueue_isr) with an ESP32-S3 device. This application receives a message during an interrupt handler with a software-triggered interrupt and checks its content. Additionally, it tries to receive a nonexistent message, ensuring that it won't block the ISR (returning immediately with the proper error code).Please note, however, that this application clearly violates kernel/userspace boundaries, so it won't be submitted upstream (it was specifically written for this implementation).
Building
After setting the alternative
nuttx-appsrepository, build the following firmware based onesp32s3-devkit:nsh:Running
Run
nsh> mqueue_isr.Results