I have developed a client application and server application which can both run on any Linux computer and communicate with each other.
I need to set some flag in each application to prevent a race condition when performing a particular operation on certain data. The operation involves reading and writing from files and deleting them afterwards.
Yes, I can set a flag in each application, for example bool in_use = true
, then an API bool is_in_use()
to get this value for example.
However, how can I ensure that the setting and reading of this flag will be atomic across all systems, hence only one application can read this flag or write it at the same time?