← Back to the chapter · Previous detail

Technical detail · What Software Prototypes Prove

Measure waits, power, and update recovery

In FreeRTOS, a task’s stack high-water mark is the least unused stack observed since it started. A value near zero leaves little safety margin. Timer jitter is the variation in when a timer fires. Queue starvation occurs when work waits too long because other work keeps taking the available time. I2C clock stretching is when a device holds the clock low to delay a transfer. A TLS handshake sets up an encrypted connection before data flows. Time each operation in the log so the team can see which wait delayed the task. Timing evidence should name the owner of each wait. An I2C read can block behind clock stretching, a TLS handshake can hold a network task, a filesystem write can stall while flash erases, and a sensor interrupt can arrive while the application is already processing an alarm. In a bare superloop, the evidence may be maximum loop time, retry counters, and watchdog reset reason. In FreeRTOS or Zephyr, it may be task priority, queue depth, stack high-water mark, timer jitter, and whether a work queue can starve a lower-priority sampling task.

The code structure also affects power and updates. A battery prototype that sleeps between samples should record wake reason, radio association time, publish duration, and current spikes measured with a power profiler or shunt fixture. An OTA prototype should record image slot, bootloader result, rollback condition, and what local state survives a failed update. These records show whether the next team can use the result. If the final runtime changes, repeat the test. Software Architecture Patterns develops the loop, state, event, and task models behind that choice.

← Back to the chapter · Previous detail