Đang mở hậu trường...
Chọn đáp án để xem tỉ lệ cộng đồng và giải thích. Câu hỏi được chọn tự động — mọi người cùng làm 1 câu mỗi ngày.
Your team maintains a shared counter updated by 32 worker threads on a 16-core server. The current implementation uses a mutex around `counter++`. A colleague proposes replacing it with a lock-free loop using an atomic compare-and-swap (CAS) on the counter, arguing it will 'eliminate blocking and always be faster'. Under sustained high contention from all 32 threads hammering the same cache line, what is the most accurate assessment of this trade-off?