I am totally confused about atomicity. Probably some of you are more familiar with this topic.
What I wanted to know is, if e.g. this is thread safe or not:
Do I need to declare long_long_global (64bit long int on a 64bit machine) as volatile? If so, why? Does it depend on the language? E.g. Java, C++? Is reading of a 64bit pointer or a long on a 64bit machine atomic? Does it depend on alignment (fields in classes are explicatively not aligned?). Do I need to read atomically, if I know that all write access is atomic? And if there are other problems, please report.
long save_state = long_long_global;
\\ do s.th., update save_state to new_save_state
}while(!atomic_compare_and_swap(&long_long_global, save_state, new_save_state);
Thanks a lot,