We use optional cookies for analytics and affiliate attribution. Essential cookies and marketing measurement are always on. Read our privacy policy

We just launched our Black Friday sale. You can use code BF2026 to get 25% off all subscriptions, valid until Nov 30th. There is a limit of 100 redemptions.

Logo

Implement Lock-Free SPSC Queue

What this preview is

Implement Lock-Free SPSC Queue is a medium quant coding problem on concurrency in Cpp, asked at Quant.

Difficulty
Medium
Topic
Concurrency
Discipline
Quant development
Language
Cpp

Implementing a lock-free single-producer single-consumer queue in C++

This medium coding problem tests your ability to design and implement a concurrent data structure using only atomic operations—a core skill for high-frequency trading and systems programming roles. You must build a fixed-capacity, bounded queue that allows one producer thread and one consumer thread to exchange data without locks, while respecting strict memory-ordering constraints.

The challenge combines several technical layers: managing a ring buffer with correct index wrapping, choosing the right memory-ordering semantics for each atomic operation (neither too loose nor overly conservative), handling the full and empty states correctly, and ensuring proper resource cleanup under RAII principles. The test suite validates thread-safe sequencing, boundary conditions, and your understanding of when relaxed vs. acquire-release orderings suffice.

  • Ring buffer index arithmetic and wraparound logic
  • Memory ordering: relaxed, acquire-release, and happens-before relationships
  • Lock-free queue state management (empty, full, partial)
  • RAII compliance and destructor safety
  • Preventing moves and copies via deleted constructors

Unlock full access to getcracked

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