Is it possible for Thread 3 to retrieve a partial value, say 0x0000FFFF from the global variable?
Your program contains a data race, therefore its behavior is undefined as far as C is concerned. In principle, yes, thread 3 could observe a value different from the variable's initial value and from the values written by threads 1 and 2, without limit.
I've always assumed that if an unsigned int
is properly aligned, a write operation is atomic, so in this case, Thread 3 would always be either 0 or 0xFFFFFFFF.
It is a mistake to try to predict the behavior of a C program based on your own model of how its source code corresponds to lower level instructions. And you do not need to attempt that if you write code whose behavior is well defined by the C language spec.
It may nevertheless be the case that your particular C implementation will never exhibit the kind of shearing you ask about under the circumstances you describe, but even if so, that does not make your racy code safe. Its behavior is still undefined, and it might still exhibit misbehavior in practice. Such as thread 3 never observing either of the other two threads' writes, for example.