Systems and low latency
Per-thread counters, part 1 of 3
FoundationNumeric answer
Per-thread counters · Part 1 of 3
Sixteen worker threads count the messages they handle in std::atomic<uint64_t> counts[16], a contiguous array that starts on a 64-byte cache-line boundary. Each thread increments only its own element.
Counting thread 0 itself, how many threads write into the cache line that holds counts[0]?
Answer with a number. Fractions, powers and expressions like 23/6 or C(52,5) are read correctly in practice.
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
More systems and low latency questions
- Messages arrive at 400,000 a second and take 2 μs each to process on one thread.Advanced · Premium
- What synchronisation does a single-producer, single-consumer ring buffer need…Advanced · Premium
- A producer writes data then sets a flag; a consumer reads the flag then the data.Expert · Premium
- A ring buffer has capacity 1024 and wraps its index with a bit mask instead of a modulo.Foundation · Premium
- Five per cent of a workload is inherently serial.Applied · Premium
- A system handles 10⁶ messages a second with an average time in system of 5 μs.Applied · Premium