Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are reads and writes atomic?

Atomic READS writes
0
Posted

Are reads and writes atomic?

0

> Suppose an integer variable is shared between threads. Is it safe to > assume that reads and writes are atomic (assuming reads and writes are > single instructions)? How big is an int? Does the machine provide instructions to read and write data with that size atomically? Does the compiler always generate the appropriate instructions to read and write ‘int’ data atomically? (E.g., “load 32-bit” rather than ‘load 64-bit’ the enclosing 64-bit cell and mask/shift.) Does the compiler/linker always ALIGN data of that size “naturally”? (If not) Does the machine still read and write data of that size atomically when the alignment is not natural? > I suspect the answer is ‘no, no standard provide such a guarantee’, > but then I’d like to know on what, if any, kind of hardware I can > expect it to fail. You’re trying to rely on a bunch of different guarantees from the hardware up through the compiler and linker. You won’t find ALL of these guarantees in any single document. The C and C++ lang

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123