Test-and-Test-and-Set Spinlock - Quant Developer Interview Question
Difficulty: Medium
Category: concurrency
Asked at: Jump Trading, Citadel, Tower Research, Optiver, HRT
Topics: concurrency, atomic, low-latency, c++17
Problem Description
Minimizing bus contention is critical for reducing latency when multiple cores contend for the same resource. The Test-and-Test-and-Set (TTAS) spinlock optimizes standard spinlocks by spinning on a locally cached copy of the lock variable, only attempting an expensive atomic operation when the lock appears free. This pattern significantly reduces coherence traffic on the CPU interconnect compared to a naive Test-and-Set approach.
Task
Implement the TTASSpinlock class in C++ to provide thread-sa
Practice this medium developer interview question on MyntBit - the LeetCode for quants with 200+ quant interview questions for Jane Street, Citadel, Two Sigma, and other top quantitative finance firms.