Proposal: a revoke() system call

John Baldwin jhb at FreeBSD.org
Thu Jul 10 02:25:13 UTC 2008


On Tuesday 08 July 2008 12:48:53 pm David Schultz wrote:
> On Tue, Jul 08, 2008, Robert Watson wrote:
> > These sorts of edge cases, btw, are one reason why I would *strongly* 
> > discourage application writers from doing things like calling close(2) on 
a 
> > file descriptor while still using it from another thread. :-)
> 
> My reaction is that apps should use standard concurrency control
> primitives, e.g., pthreads primitives or message queues, to
> coordinate the activities of multiple threads. The are scads of
> ways to introduce race conditions when updating various aspects of
> the process state (the fd table, in this case). Once we start
> adding special-purpose APIs to facilitate clever lock-free tricks
> in very specific cases, when will it stop? Next we'll want a
> special version of exit(), a special version of sigaction(), a
> special version of free(), and so forth.

I agree, this just sounds like an application bug.  Plus, even if we add a new 
system call that rescues drowning file descriptors it won't really help with 
writing a portable application anyway unless you get other OS's to adopt a 
similar API.

Just use the extra pipe for messages and/or real locking (in your original 
example you have an obvious race with the use of 'mystructure' and the 
solution is Don't Do That(tm)).

-- 
John Baldwin


More information about the freebsd-arch mailing list