Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.unix.wizards Subject: Re: Tty queues Message-ID: <7742@utzoo.UUCP> Date: Wed, 4-Mar-87 16:52:23 EST Article-I.D.: utzoo.7742 Posted: Wed Mar 4 16:52:23 1987 Date-Received: Wed, 4-Mar-87 16:52:23 EST References: <3293@rsch.WISC.EDU> Organization: U of Toronto Zoology Lines: 22 Keywords: Kernel question, ttys, write/read > It's not clear where the stuff gets mixed up. We're guessing that the > problem is in printf, that printf makes multiple calls to write()... Could be, depends on *exactly* what's been done to your printf. Old ones generally write a character at a time, most new ones try to do only one write (but often have only finite buffering available). > ...If I made just one call to write with the whole string, would the problem > go away? Or is it something like the copy getting interrupted by > new tty i/o (I hope not). You're not going to like this, but in general there is *no* guarantee about the order or interleaving of tty output coming simultaneously from multiple sources. None. The system will *try* to complete a write as an atomic entity, but there is only a finite amount of buffering between the write and the device, and if there's no room, the write will have to wait. If more than one write is waiting for buffer space, which one gets first grab when more space appears is unpredictable. That's my recollection, anyway. Much depends on details, which differ between Unix variants. -- "We must choose: the stars or Henry Spencer @ U of Toronto Zoology the dust. Which shall it be?" {allegra,ihnp4,decvax,pyramid}!utzoo!henry