Logo

Question preview

How do I test ts 1?

What this preview is

About this preview

How do I test ts 1? is a medium quant interview question on concurrency in Cpp.

Unlock full access to getcracked

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

Testing concurrent code: memory ordering in C++ thread synchronization

This is a medium-difficulty C++ concurrency question that tests your ability to reason about memory ordering guarantees in multithreaded programs. Rather than writing the implementation, you are tasked with writing a test for someone else's code—which requires understanding what synchronization primitives actually promise.

The question asks you to identify the minimum memory ordering needed to reliably test a custom jthread implementation. This probes whether you understand the spectrum of C++ memory orders—from relaxed (no synchronization) through acquire-release to sequential consistency—and can reason about when each is necessary to prevent data races and ensure visibility across threads. Strong answers avoid over-synchronization (which hides bugs and wastes performance) while guaranteeing correctness.

  • Memory ordering semantics in <atomic>
  • Happens-before relationships and synchronizes-with edges
  • Thread lifetime and join guarantees
  • Data race detection and test reliability