Path: utzoo!attcan!uunet!wuarchive!mailrus!iuvax!rutgers!texbell!sequoia!tntdev!wgb From: wgb@tntdev.tnt.COM (William G. Bunton) Newsgroups: comp.unix.questions Subject: Re: Are terminal writes atomic? Message-ID: Date: 8 Oct 89 14:20:28 GMT References: <-286379999@hpcupt1.HP.COM> <1118@cs.yale.edu> <186@promark.UUCP> <19972@mimsy.UUCP> <191@promark.UUCP> Reply-To: wgb@tntdev.TNT.COM (William G. Bunton) Organization: Tools & Techniques, Austin TX Lines: 45 In-reply-to: mark@promark.UUCP's message of 7 Oct 89 19:17:44 GMT On 7 Oct 89 19:17:44 GMT, mark@promark.UUCP (Mark J. DeFilippis) said: Mark> Summary: I should have qualifed this... Mark> In article <19972@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > In article <186@promark.UUCP> mark@promark.UUCP (Mark J. DeFilippis) writes: > >How about we take this further. The answer to this question is an > >undocumented feature of write() under Unix. Several Authors note this > > Of course, it might be undocumented because it is false. > > On Berkeley systems (4BSD, at least), writes to character devices are Mark> Indeed I should have qualified my statement, however almost Mark> everyone is familiar with Rochkind's _Advanced Unix Programming_ Mark> book, and they are aware it is a SYSTEM V book, not a 4BSD Unix Mark> book. Under System V, it is a known undocumented item. By Mark> undocumented, I mean it was left out of the documentation and Mark> under ALL true Unix System V systems, atomic writes at the Mark> system call level are guaranteed. Yes, 4BSD is different and Mark> causes much grief with which I am familiar with. That is why I Mark> am glad that most porting I do is from 4.XBSD to System V, and Mark> not the other way around! I assume you don't get out from under Mark> 4.XBSD that often huh? But Mark, it isn't true under System V, either. Bach says (Design of the UNIX Operating System) section 10.3.2, page 33: "Output data could also be garbled at a terminal because a writing process may sleep in the middle of a *write* system call while waiting for previous output data to drain from the system. The kernel could schedule other processes that *write* the terminal before the original process is rescheduled. Because of this case, the kernel does *not* guarantee that the contents of the data buffer to be output by a *write* system call appear contiguously on the terminal." Note the emphasis is his, not mine. I think this is why atomic terminal writes are not documented for System V: because they are not guaranteed atomic. Bill -- William G. Bunton wgb@tntdev.tnt.com Tools & Techniques, Inc. Austin, TX {cs.utexas.edu,uunet}!tntdev!wgb