1.8 KiB
1.8 KiB
K10 — Queue and StaticQueue<T, N>
Position
- Series: FreeRTOS C++
- Lesson: L09, card K10
- Duration: 30 minutes
- Platform: Hazard3 / RV32I, FreeRTOS V11.3.0
- Message: 12-byte trivial
Sample, capacity 2
Outcome
The student explains byte-copy semantics, designs a trivial message, proves a copy survives source mutation, compares dynamic and caller-owned static queue storage, and handles full/empty states with explicit bounded timeouts.
Lesson plan
| Time | Mode | Evidence |
|---|---|---|
| 0–5 | type contract | Sample passes; owning VectorV1 fails |
| 5–10 | create | dynamic cost 128 B; static delta 0 B |
| 10–15 | copy | send, mutate source, receive unchanged copy |
| 15–20 | storage | inspect first 12 static storage bytes |
| 20–25 | full/timeout | capacity 2; third send fails after 2 ticks |
| 25–30 | FIFO/drain | values 0x2222 then 0x3333; empty receive fails |
Acceptance
sizeof(Sample)==12reaches both create APIs;- dynamic cost is positive and recovered by RAII destruction;
- static create has zero heap delta and its buffers are in
.bss; - received value remains 0x1111 after source becomes 0xDEAD;
- storage snapshot equals the first sent
Samplebyte-for-byte; - full count is 2, third send returns false after at least 2 ticks;
- FIFO and non-blocking empty receive are correct;
- non-trivial owning message fails for the pinned static-assert reason;
- target exits with PASS.
Main traps
- Queue storage is a byte copy, not a C++ object owner.
sizeof(pointer)plus an object address is a different and invalid contract.- A trivially-copyable pointer still needs an external lifetime policy.
portMAX_DELAYmust not be hidden as a convenient default.- Static queue control and byte storage must both outlive the queue.