Strictly speaking, no (although "yes" would also be a valid answer, and arguably a more correct one for the general case).
Depending on what you need/want, you may very well just use atomic operations using functions like e.g. OSAtomicIncrement32
or OSAtomicCompareAndSwapPtr
which is not locking.
Note, however, that even if one operation is atomic, two individually atomic, consecutive operations are not atomic in their entirety. Thus, if for example, you want to update both state
and someValue
consistently, then going without a lock is sheer impossible if correctness matters (unless, by coincidence, they're small enough so you can cheat and squeeze them into a single larger atomic type).
Also note that even though you either need to lock or use atomic operations for program correctness, you can occasionally very well "get away" without doing so. That's because on the majority of platforms, ordinary loads and stores to properly aligned memory addresses are atomic anyway.
However, do not get tempted, this is not as good as it sounds, and indeed not a good thing at all -- relying that things will just work (even if you "tested", and it works fine by all means) creates the kind of program which works fine during development and then causes a thousand support tickets a month after shipping, and there's no obvious indication to what's gone wrong.