Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utcsrgv.UUCP Path: utzoo!utcsrgv!dave From: dave@utcsrgv.UUCP (Dave Sherman) Newsgroups: net.unix Subject: How to get printf to call write(2) only once? Message-ID: <3769@utcsrgv.UUCP> Date: Fri, 6-Apr-84 15:26:52 EST Article-I.D.: utcsrgv.3769 Posted: Fri Apr 6 15:26:52 1984 Date-Received: Fri, 6-Apr-84 17:32:51 EST Organization: The Law Society of Upper Canada, Toronto Lines: 40 In running benchmarks on a particular computer to simulate our CAI application, I seem to have run into a bottleneck in the terminal I/O, specifically the O. This is a modified version 7 system (Perkin-Elmer Edition VII Workbench). It seems to me that a call to printf should trigger a single call to write, but that's not happening. I looked at the stdio source on our PDP-11 v7 system, and this is what happens: 1. printf calls _doprnt 2. _doprnt calls _strout on the whole string 3. _strout calls the putc macro 4. since _cnt is 0 (on a terminal line), flsbuf is called immediately 5. flsbuf calls write on one character. Now, I realize I can use setbuf to buffer stdout, but I don't want buffered output. I simply want to reduce the number of character interrupts generated per printf. I suppose I can do: myprintf(a,b,c,d) { printf(a,b,c,d); fflush(stdout); } and run setbuf on stdout, but that's (a) kludgey and (b) not guaranteed to pass the args to printf properly on any particular machine. Any suggestions? Could _strout be modified to set a flag that _flsbuf looks at, so that only one call to write(2) is done? Has someone done this already? Thanks. Dave Sherman The Law Society of Upper Canada Toronto -- {allegra,cornell,decvax,ihnp4,linus,utzoo}!utcsrgv!dave