Skip to content

Commit 57b7d27

Browse files
committed
zephyr: sync: channel: Add IRQ safety comment
Add a bit of commentary as to the limited situations where it safe to use channels from IRQ context. Signed-off-by: David Brown <[email protected]>
1 parent 9ef0b55 commit 57b7d27

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

zephyr/src/sync/channel.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
//! In other words, `zephyr::sys::Queue` is a Rust friendly implementation of `k_queue` in Zephyr.
1111
//! This module provides `Sender` and `Receiver`, which can be cloned and behave as if they had an
1212
//! internal `Arc` inside them, but without the overhead of an actual Arc.
13+
//!
14+
//! ## IRQ safety
15+
//!
16+
//! These channels are usable from IRQ context on Zephyr in very limited situations. Notably, all
17+
//! of the following must be true:
18+
//! - The channel has been created with `bounded()`, which pre-allocates all of the messages.
19+
//! - If the type `T` has a Drop implementation, this implementation can be called from IRQ context.
20+
//! - Only `try_send` or `try_recv` are used on the channel.
21+
//!
22+
//! The requirement for Drop is only strictly true if the IRQ handler calls `try_recv` and drops
23+
//! received message. If the message is *always* sent over another channel or otherwise not
24+
//! dropped, it *might* be safe to use these messages.
1325
1426
extern crate alloc;
1527

0 commit comments

Comments
 (0)