delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/14/19:30:23

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: wierd problem
Date: Sat, 15 Nov 1997 18:15:39 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 31
Message-ID: <346DE6CB.1825@cs.com>
References: <01bceff6$b2df4060$63206ccb AT ashod> <346B528D DOT 610B AT nic DOT smsu DOT edu> <346C15AE DOT 21C6CB2 AT usa DOT net>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp203.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

J P Morris wrote:
> 
> Presumably this only happens with UNIX C compilers.
> This never happened with Borland, and it had me confused for a while.

Not quite.  While Unix may use buffered output streams, it does _not_
have a conio interface.  So there can be no conflict between the two
like there is on DOS.  :)  Unix may use other types of direct screen
interface; I'm not an expert in those.

Anyway, ANSI makes no guarantees about the buffered status of stdout;
stating only that it can be anything from unbuffered to line-buffered. 
Borland, et. al., being 16-bit compilers, can send text directly to DOS
with little overhead, so it makes sense for them to be unbuffered. 
DJGPP, however, is a 32-bit compiler, and interfacing with the DOS
filesystem to write out text requires a PM<->RM mode switch, which is
fairly expensive in terms of cycles.  So it makes sense to write out
text as seldom as is legal within ANSI.

For a test of what I am saying, find any DJGPP program that produces
voluminous text output, and turn off stdout buffering with setbuf(
stdout, NULL );.  The resulting code should run noticeably slower than
before.

hth
-- 
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I |     mailto:fighteer AT cs DOT com      |
| Descent 2: The Infinite Abyss - The greatest Internet game of all |
| time just got better!  This time, you're going all the way down...|
---------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019