Skip to main content

Practice ยท 5 of 5

volatile Makes It Honest

CHALLENGE
Difficulty: advanced+25 XP

A file-scope static volatile int ticks = 0; is already in your editor. Implement int bump_ticks(void) (adds 1, returns the new value), void reset_ticks(void), and int ticks_between(void (*work)(void), int expected) which resets, runs work(), and returns 1 iff ticks equals expected โ€” proving every write actually happened because volatile forbids collapsing them.

Back to lesson: Practice: UB and Optimizer Drills