Logo

Question preview

Spuriously failed...

What this preview is

About this preview

Spuriously failed... is a easy quant interview question on concurrency in Cpp, asked at Intel.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

What this C++ concurrency interview question tests

This is an easy concurrency question that probes understanding of the compare_exchange_weak operation on atomic types in C++. It targets candidates' awareness of a subtle but critical behaviour: spurious failure, where a compare-and-swap instruction can report failure even when the expected value matches the current value.

The question asks you to identify the correct pattern for guarding against spurious failure in a real code snippet. Firms like Intel ask this to ensure candidates writing lock-free code understand the difference between weak and strong compare-exchange operations, and know when (and how) to retry atomically.

  • Weak vs. strong atomic compare-exchange semantics
  • Loop patterns for atomic operations
  • Memory ordering and synchronisation