It is possible to allocate CPU to thread2 in the mid of a + b? where a + b is in thread1.
In C/C++ , It is not atomic operation. If you will check assembly program of this. It would be divided in getting value from registers, operation over those and storing back values. Even a++ is not atomic operation.
Certain architectures support atomic addition or subtraction instructions, but there is no guarantee that the compiler would use them. If it is not performance-critical part of your code, you'd simply use a mutex.
What is structure padding and how it is used at processor level?
What is the difference between Pipe and FIFO?