# K10 — Queue and StaticQueue ## 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)==12` reaches 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 `Sample` byte-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 1. Queue storage is a byte copy, not a C++ object owner. 2. `sizeof(pointer)` plus an object address is a different and invalid contract. 3. A trivially-copyable pointer still needs an external lifetime policy. 4. `portMAX_DELAY` must not be hidden as a convenient default. 5. Static queue control and byte storage must both outlive the queue.