Easy
A hot counter under write-back vs. write-through L1 policies
A single thread increments a volatile uint64_t counter one million times in a tight loop. volatile forces the compiler to emit a real load and store on every iteration, nothing else touches the counter's cache line, and the line stays resident in L1 for the whole loop. Compare two L1 data caches that are identical except for their write policy: Cache A is write-back, Cache B is write-through (assume no write buffer coalesces stores between L1 and L2). Roughly how many writes does each cache send to L2 during the loop?
main.cpp
volatile uint64_t counter = 0;
for (int i = 0; i < 1'000'000; ++i) {
counter = counter + 1; // one load and one store per iteration
}32 of 47 in Computer Architecture