Is the write(2) system call atomic
Jerry Feldman
gaf at blu.org
Sat Apr 8 08:39:55 EDT 2006
On Sat, 08 Apr 2006 00:31:29 UTC
John Chambers <jc at trillian.mit.edu> wrote:
> I've always understood that there was a single per-open data
> structure that contains things like the kernel file buffer, but there
> was also a per-process structure that contains the offset. Otherwise,
> you'd have an lseek() call in one process affect the other's offset,
> which would be truly bizarre to try to debug.
I found the answer I was looking for thanks to Robert La Ferla
http://marc.theaimsgroup.com/?l=linux-kernel&m=107375454908544
The relevant part of this is from Linus.
"There are file descriptors that have atomicity guarantees (pipes(,
but regular files do not".
The person who originally posted the question on another list had
inferred that write(2) was atomic from the following: "Write requests
of {PIPE_BUF} bytes or less are guaranteed not to be interleaved
with data from other processes doing writes on the same pipe".
--
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20060408/c63590c4/attachment.sig>
More information about the Discuss
mailing list