Sometimes we do not need to make per variable membars. For instance the atomic logic for locking/unlocking a mutex can all be relaxed. BUT, we
need to add in the right membars, so it tends to go like this: ___________________
atomic_mutex_lock(); // all relaxed
-a-a std::atomic_thread_fence(std::memory_order_acquire);
-a-a-a-a {
-a-a-a-a-a-a-a-a // critical section...
-a-a-a-a }
-a-a std::atomic_thread_fence(std::memory_order_release); atomic_mutex_unlock(); // all relaxed
___________________
Its more of a SPARC way of thinking about where to place memory barriers.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 54 |
| Nodes: | 6 (1 / 5) |
| Uptime: | 20:59:17 |
| Calls: | 742 |
| Files: | 1,218 |
| D/L today: |
6 files (8,794K bytes) |
| Messages: | 185,811 |
| Posted today: | 1 |