Lets say I have two shared variables a,b which are related to each other. When multiple applications share these shared variables, access to them needs to be an atomic operation, otherwise the relation may break. So to ensure mutual exclusion, I'll put their modification under a critical section protected by lock.
a := something
b := something
Lets say my hardware/OS/compiler supports atomic variables. Then I modified my above code as follows.
atomic a := something
atomic b := something
Can this code ensure mutual exclusion, when accessed by multiple applications?