Go Memory Model: How to assign values to a field with proper synchronization

Advertisements Below is the core portion of my implementation for Promise in Go. // A promise represents the future result of a call to a function. type promise struct { // state is the current state of this promise. state int32 // done is closed when execution completes to unblock concurrent waiters. done chan struct{}… Read More Go Memory Model: How to assign values to a field with proper synchronization

How to solve producer-consumer problem using atomic_compare_exchange_weak?

Advertisements 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… Read More How to solve producer-consumer problem using atomic_compare_exchange_weak?

Why didn't x86 implement direct core-to-core messaging assembly/cpu instructions?

Advertisements After serious development, CPUs gained many cores, gained distributed blocks of cores on multiple chiplets, numa systems, etc but still a piece of data has to pass through not only L1 cache (if on same core SMT) but also some atomic/mutex synchronization primitive procedure that is not accelerated by hardware. I wonder why didn’t… Read More Why didn't x86 implement direct core-to-core messaging assembly/cpu instructions?