|
|
|
|
|
|
| Author |
Message |
Alan J Rosenthal *nix forums beginner
Joined: 14 May 2005
Posts: 1
|
Posted: Sat May 14, 2005 10:05 pm Post subject:
unlink atomicity?
|
|
|
I'm writing a little web thingy using the CGI interface. My program will
claim appointment times. I'm thinking of making the claiming of a time
be represented by the unlinking of a file, and there will be one file
(remaining) for each available time.
But unlike the properties we're used to for link() and creat(), I don't
know of any atomicity guarantees for unlink() (and TFM doesn't specify).
If two processes unlink() a file at about the same time, and not involving
NFS or anything nasty like that, is it guaranteed that exactly one of them
will succeed and the other will get ENOENT? Or is it possible for both of
them to get a zero return value? Even worse, is it possible for them both
to get ENOENT but the file is actually unlinked?
I could use another method to do my atomic operation (e.g. link() or creat()!),
but I need to unlink the file anyway, so it seems perfect as a synchronizer...
if there is the above atomicity guarantee.
This will actually run on linux at the moment, but I'm at least as interested
in the unix answer as well, in the unlikely case that they are different.
Or any information about which versions of unix have which behaviour, etc.
I'm imagining that it's atomic, in the absence of nasties such as NFS, but
I'm not going to rely on that unless I have some actual information to that
effect! I'd also want to know if the answer changes for multi-CPU systems.
thanks,
ajr |
|
| Back to top |
|
 |
Josip Gracin *nix forums beginner
Joined: 20 Feb 2005
Posts: 42
|
Posted: Mon May 16, 2005 8:33 am Post subject:
Re: unlink atomicity?
|
|
|
On Sun, 15 May 2005 00:05:40 +0000, Alan J Rosenthal wrote:
| Quote: | If two processes unlink() a file at about the same time, and not involving
NFS or anything nasty like that, is it guaranteed that exactly one of them
will succeed and the other will get ENOENT?
|
Based on what I see in Solaris 8 and Linux 2.6 source code, both systems
synchronize the unlink operation. Therefore, only one process will get
0 return value from unlink(). |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Fri Jan 09, 2009 6:16 am | All times are GMT
|
|
Car Credit | Loans | Personal Loans | Keeping Aquarium Fish | Credit Card Advice
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|