61 lines
1.7 KiB
Markdown
61 lines
1.7 KiB
Markdown
# K10 — Queue<T> and StaticQueue<T, N>
|
|
|
|
K10 adds a typed C++ boundary over FreeRTOS byte-copy queues. Both wrappers
|
|
unconditionally require `T` to be trivially copyable, pass `sizeof(T)` to the
|
|
kernel and expose bounded `send`/`receive` calls whose default timeout is zero.
|
|
|
|
- `Queue<T>` owns a dynamically created queue and deletes it in its destructor;
|
|
- `StaticQueue<T,N>` references caller-owned `StaticQueueStorage<T,N>` in
|
|
`.bss` and creates no heap allocation;
|
|
- neither wrapper can be copied or moved.
|
|
|
|
## Hazard3 evidence
|
|
|
|
```text
|
|
dynamic queue cost = 0x80 = 128 bytes
|
|
Sample item size = 0x0c = 12 bytes
|
|
received copied value = 0x1111 (source mutated to 0xDEAD)
|
|
full send timeout = 2 ticks
|
|
second FIFO value = 0x3333
|
|
```
|
|
|
|
Static creation leaves the heap unchanged. Its native handle equals the
|
|
caller-supplied control block, and both control/storage addresses lie outside
|
|
`ucHeap`. Destruction restores the exact dynamic baseline.
|
|
|
|
## Build
|
|
|
|
```sh
|
|
make check
|
|
```
|
|
|
|
The host suite also compiles a trivial `Sample` and requires compilation of a
|
|
minimal owning `VectorV1` message to fail with:
|
|
|
|
```text
|
|
Queue<T> requires T to be trivially copyable
|
|
```
|
|
|
|
## Debug
|
|
|
|
```gdb
|
|
b queue_debug_checkpoint
|
|
p g_dynamic_queue_cost
|
|
p g_static_control_address
|
|
p g_static_bytes_address
|
|
p g_static_first_item_bytes
|
|
p g_copy_source_after_mutation
|
|
p g_copy_received_value
|
|
p g_full_count
|
|
p g_timeout_ticks
|
|
p g_fifo_values
|
|
p g_queue_pass
|
|
```
|
|
|
|
## Scope boundary
|
|
|
|
FreeRTOS queues copy bytes, not object lifetime. Owning objects must not cross
|
|
this boundary by value. A pointer may be trivially copyable but then lifetime
|
|
and ownership remain an explicit application contract. No wrapper silently
|
|
uses `portMAX_DELAY`.
|