From owner-freebsd-hackers Fri May 12 14:51:39 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp02.teb1.iconnet.net (smtp02.teb1.iconnet.net [209.3.218.43]) by hub.freebsd.org (Postfix) with ESMTP id D14F237B94A for ; Fri, 12 May 2000 14:51:35 -0700 (PDT) (envelope-from babkin@bellatlantic.net) Received: from bellatlantic.net (client-117-169.bellatlantic.net [151.198.117.169]) by smtp02.teb1.iconnet.net (8.9.1/8.9.1) with ESMTP id RAA01409; Fri, 12 May 2000 17:51:21 -0400 (EDT) Message-ID: <391C7CDA.F9B477B7@bellatlantic.net> Date: Fri, 12 May 2000 17:51:22 -0400 From: Sergey Babkin X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 4.0-19990626-CURRENT i386) X-Accept-Language: ru, en MIME-Version: 1.0 To: Alfred Perlstein Cc: Ville-Pertti Keinonen , FengYue , hackers@FreeBSD.ORG Subject: Re: Why this works? References: <20000511210915.A38341@Hamilton-ppp44812.sympatico.ca> <864s84cq35.fsf@not.demophon.com> <20000512005806.A29302@fw.wintelcom.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > > * Ville-Pertti Keinonen [000511 22:49] wrote: > > > > fengyue@bluerose.windmoon.nu (FengYue) writes: > > > > > loop. Now, the third program reads 4K of data from /tmp/pagetest > > > and exit if the 4K data does not contain all 'A's nor 'Z's. 3 programs > > > run concurrently on the same machine (3.4). No lock in the code whatsoever, > > > > Not quite. If FreeBSD didn't perform locking, operations affecting > > single filesystem blocks would probably be atomic (as long as the > > userland buffer is in memory). > > > > However, FreeBSD does perform locking in read(2) and write(2) for > > local files, so your third program should never fail and exit. > > > > Note that the system call interface does not guarantee reads or writes > > to be atomic, this just happens to be how it is implemented at the > > moment. > > Afaik several Unix standards mandate this behavior, Linux doesn't > follow this standard though. Sounds like one more of these subtle weirdnesses in Linux that annoy me so much :-( Solaris seems to be another example a system with not quite atomic writes. The writes themselves seem to be atomic but in append mode the positioning at the end of file is not atomic with writes. So when appending to a log file from multiple sources the messages tend to overlap (be written at the same position). -SB To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message