shurd at sasktel.net
Wed Jun 30 18:20:43 PDT 2004
> > Has anyone looked at this? Does anyone have any comments?
> > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/50827
> I don't think you'll ever find anyone interested in file locking
> anymore. Since they're all advisory, anyway, you can just implement them
> at a higher level in your application. BSD and System V IPC mechanisms
> already are very good building blocks here for system-scoped locks.
Hrm? I'm sort of confused... file locking is still the best way of doing
erm... file locking. A few points:
1) File locking works with any program using the file locking API.
Hand-rolled implementations will only work with other programs which use
the same hand-rolled routines.
2) File locking works across NFS, so you aren't limited to the local
3) There's no simple way of doing per-descriptor locks using BSD and SysV
IPC... ie: locks which are automatically released when the file descriptor
used to obtain the lock is released. This also of course means programs
which core won't leave stale locks laying around.
Essentially, implementing locks at a higher level is alway more difficult,
usually more prone to problems, and in some cases introduces more overhead
than the rest of the program.
The only reason I can think of for implementing locks at a higher level is
for cross-platform code...
More information about the freebsd-hackers