9fans archive / 1998 / 02 / 21 /    prev next

From: G. David Butler gdb@dbS...
Subject: [9fans] create(2)/open(2) race for file creation
Date: Sun, 8 Feb 1998 09:48:34 -0600

>From: forsyth@cal...
>>>Any comments?
>
>it's hopeless trying to offer advice without knowing
>what you're actually trying to achieve at the application level
>(except that i can already say i really don't approve of the proposed
>change to create).
>
>what's the aim?

I have data coming from many sources that have a unique key
associated with it.  I want to be able to receive this data
using the key as a file name without the data being corrupted.
This data may need to be updated at times.  I have serveral
processes receiving this data and I don't want the data if I
already have it because my copy may have already been updated.

If I use the algorithm:

if stat fails {
	create
	write
	close
}

I have no guarantee about the amout of time between the stat
and the create for each process.  What I need is a atomic test
and set on each possible name.  create(5) give me that, but there
is no way to get to it from the available system calls.  I can't
use rendezvous because the processes are on different cpu servers.

So if you don't want to change create(2), do we implement O_EXCL?

David Butler
gdb@dbs...