How to solve producer-consumer problem using atomic_compare_exchange_weak?
I am implementing the ‘producer-consumer problem’ in C, which solves the synchronization problem of redundant production, redundant consumption, and consuming unproduced items when multi-threading. bool expected = false; while (!atomic_compare_exchange_weak(&lock, &expected, true)) expected = false; In order to prevent duplicate access of the process, the atomic_compare_exchange_weak was used. I know that the atomic_compare_exchange_weak can block… Read More How to solve producer-consumer problem using atomic_compare_exchange_weak?