TECHNOLOGY

Zephyr work items coalesce queued submissions; they are not event counters

In this article
THE QUICK TAKE

Use a work item to signal available work, with a separate bounded data or count contract when every event matters; do not infer handler multiplicity from submit calls.

Every sensor interrupt submits the same object

A sensor interrupt submits a reusable work item for inference. A burst arrives while that item is waiting behind other handlers. The application counts each submit call as another queued classification, then finds fewer handler calls than events. This can be the documented coalescing behavior rather than scheduler corruption. Decide whether the application wants to process the latest state, drain retained samples or preserve every event. Those requirements need explicit data accounting beyond the identity of a single work item.

Already queued means the existing entry remains

The workqueue lifecycle guide states that submitting an already queued work item leaves its position unchanged and the queued work is performed once. A submit-call counter is therefore not a queue-depth counter or completed-sample denominator. Preserve the item’s identity and the API outcome when diagnosing a burst. Creating duplicate metrics for every submission cannot manufacture missing payloads; the data that must survive coalescing needs its own storage and ownership contract.

Running and queued are not interchangeable states

The API reference distinguishes already submitted, newly queued and running work queued for another execution. Avoid the stronger false rule that repeated submission can never cause another run. A work item can be running and queued again. Interpret the documented result for the actual state and installed API. Likewise, a busy-state snapshot can become obsolete before the next action; a check followed by an unsynchronized decision is not a complete event-publication protocol.

Separate the doorbell from the data

If every sample matters, retain samples in an appropriately bounded queue or pool with explicit overrun behavior. The work item can act as a doorbell telling the handler to drain available work. If only the latest state matters, document that replacement policy and preserve a coherent snapshot for inference. A counting scheme also needs overflow and synchronization rules. None of these designs follows automatically from k_work submission; choose the data contract before claiming how many classifications the system owes after a burst.

Propose separate queued and running burst fixtures

Delay the workqueue so repeated submissions definitely target an already queued item, retaining harmless distinct sample markers. Then repeat with a running handler and observe the documented requeue outcome. Check the data ledger separately from handler-call counts, including arrivals near the handler’s final drain check. Acceptance is correct retained-sample processing or explicit replacement/overrun reporting. No Zephyr workqueue was executed here; these fixtures define semantic evidence without inventing scheduler throughput, loss rates or a universal interrupt-to-inference latency.

Use the correct denominator for evaluation

Explicit persistent-kernel queues illustrate why work accounting matters. Embedded pipeline measurement distinguishes stages and useful completed work. For Zephyr, report sensor events, retained samples, submission outcomes, handler runs and classified samples separately. Their counts need not match under a deliberate coalescing policy. This makes missing-data investigation precise without blaming the model for an event that never had an independently retained inference input.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles