I have two processes reading/writing same files. So I wanna create a lock between them. My idea is to create a file in that folder named file.lock containing the process identification information. The process which has the lock creates the file and releases the lock by deleting it.
My question is:
Is it possible that while process A is creating the file and before the file is eventually created, process B checks the file and finds that it's not there, and thus the mutex fails?
How can
wait()
method be implemented in this scenario?