Reputation:
In C (Linux AND Windows) if I want to manage a "perfect" concurrent file access like :
Do you think I have to use mutex ? Should O_EXCL work too ? Better options ?
Upvotes: 1
Views: 1061
Reputation: 61
if A and B are different threads, mutex or symaphores can be used to achieve synchronization between them. you can find more information on mutext at http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
Upvotes: 1
Reputation: 96109
Are A and B threads or programs?
If they are separate programs it's probably better to only have one have the file open for writing at once, even if you manage to synchronise access between two apps you have to be very careful about flushing buffers to ensure that they really are in the state you expect.
Upvotes: 1