27 ms·
You litterally cannot implement the C++11 memory model on early alphas without either 1) doing the equivalent of CAS (or LL/SC in this case) for every single a
by gpderetta 7y ago
You litterally cannot implement the C++11 memory model on early alphas without either
1) doing the equivalent of CAS (or LL/SC in this case) for every single access less than 32 bits completely destroying performance.
2) declaring that a char (and a byte) is 32 bit sized, which implies no posix.
It was very bad. This was fixed in subsequent alphas though.
- BeeOnRope 7y agoInteresting, TIL I learned that POSIX implies CHAR_BIT == 8. I knew POSIX required a lot of other things that are unspecified in C/C++ but usually have a single sane implementation, but not that particular one. I know I have static_assert(CHAR_BIT == 8, ...) sprinkled around in quite a few places. One day I'm going to write a header that just checks a big list of things that are "obviously sane" but not actually specified in C/C++, and error out if any are not true. Then I can include this in every project and just code in this new sane world. Not strictly portable, but "portable to where it matters".
- cwzwarich 7y agoWith the C++ memory model you can make std::atomic<char> larger than char.
- gpderetta 7y agoThe issue is not with atomic but with all non atomic accesses. The standard guarantees that two concurrent writes to contiguous but distinct char-sized memory location to be legal and data-race-free.