9fans archive / 1998 / 02 / 23 / prev next
From: G. David Butler gdb@dbS...
Subject: [9fans] create(2)/open(2) race for file creation
Date: Sun, 8 Feb 1998 10:16:01 -0600
>From: "Dave Presotto" <presotto@pla...>
>This is why I got ken to introduce exclusive access files. I
>use one as a lock for a directory/file/whatever.
I tried that with:
open(lock file in directory)
if open fail {
create
write
close
}
close(lock file)
But the 9p overhead and the bottleneck created convinced me that
it was not a good idea. The above becomes:
open(2)
walk(5)
open(5)
open(2)
walk(5) [fails]
create(2)
walk(5) [create(2) trying to determine to send the create(5)]
create(5)
write(2)...
close(2)
clunk(5)
close(2)
clunk(5)
If we change create(2) to do create(5) then:
if create() success {
write
close
}
becomes:
create(2)
create(5)
write(2)...
close(2)
clunk(5)
Much better.
David Butler
gdb@dbS...