Practice ยท 1 of 3
CAS Loop: Double Until Even
CHALLENGE
Difficulty: advanced+25 XP
ISO C11. Implement void double_until_even(atomic_int *v) โ repeatedly double *v using a compare-exchange loop until the new value is even. Every doubling must go through one atomic CAS (no plain *v = *v * 2).
Press Submit to check your solution.
Back to lesson: Practice: Atomics and Ordering Drills