Quantcast
Channel: Is changing a pointer considered an atomic action in C? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Is changing a pointer considered an atomic action in C?

$
0
0

If I have a multi-threaded program that reads a cache-type memory by reference. Can I change this pointer by the main thread without risking any of the other threads reading unexpected values.

As I see it, if the change is atomic the other threads will either read the older value or the newer value; never random memory (or null pointers), right?

I am aware that I should probably use synchronisation methods anyway, but I'm still curious.

Are pointer changes atomic?

Update: My platform is 64-bit Linux (2.6.29), although I'd like a cross-platform answer as well :)


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles



Latest Images