In C++, I feel like I've always been lead to believe that things like var++ and var-- are reasonably threadsafe - AKA - you have a guarantee that your value will increase or decrease at some point in time.
It was upon this belief that I built my understanding of non-blocking algorithms for thread-safe operations. Yet, today I'm in shock, as I have a variable that is not getting incremented - and am therefore questioning the validity of a large amount of my past work.
In a small program, I have a global variable initialized at 0. Eight P-Threads are started up that each call varname++ a total of 1024 times, totalling to 8*1024 increments. Yet after all threads have finished executing, the value of varname is significantly less than 8*1024.
Did I miss the boat here? Can someone please enlighten me?