DescriptionQ792
Q792FWArchASIC interview problem
Build an interrupt-safe sliding-maximum telemetry filter
TechniquesFirmwareMonotonic queueLock-free snapshot
DifficultyHard
TopicData Structures
LanguageC
Requirements4 checkpoints
01
Problem
Build a fixed-memory sliding maximum written by one interrupt service routine (ISR) and read by a task, with bounded retries, wrap-safe sequence ages, newest-equal tie behavior, and atomic publication.
Type declarationC
typedef struct { int32_t value; uint32_t seq; } tm_node_t;
typedef struct telemetry_max_ref telemetry_max_ref;
bool telemetry_max_configure(telemetry_max_ref *filter, uint32_t window);
void telemetry_max_isr_push(telemetry_max_ref *filter, int32_t value);
bool telemetry_max_read(const telemetry_max_ref *filter,
int32_t *maximum, uint32_t *maximum_seq);Example input and output
Use this case to check your interpretationInput
window=3; ISR samples by sequence=[4,2,5,5]Output
published maxima=[4,4,5,5]; newest equal maximum is the final 5Explanation
Removing older values less than or equal to each new sample keeps the deque decreasing and gives equal values newest-wins behavior.
02
Requirements (4)
- Initialization accepts windows 1 through 64, publishes window last, and leaves the object unchanged after invalid reconfiguration.
- Maintain a decreasing queue, remove older values less than or equal to the new sample, and expire by unsigned sequence age.
- Publish full, maximum, and sequence between odd and even generation values using release semantics.
- A reader uses acquire loads, accepts only the same even generation before and after, tries at most three snapshots, and preserves outputs on every failure.
