www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/10/05:54:00

Message-ID: <34166E20.543C@bo.dada.it>
Date: Wed, 10 Sep 1997 11:53:36 +0200
From: Diego Zuccato <dz AT bo DOT dada DOT it>
Organization: CyberSpace Software Labs BBS
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp-workers AT delorie DOT com
Subject: Transfer buffer (Was: Re: fread slowstart)
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970910115211 DOT 9494D-100000 AT is>

Eli Zaretskii wrote:

> This is incorrect.  The child program is a different process, it has
> its own DPMI-related structures; in particular, the selectors are
> different.  It even has its own PSP, so even DOS knows they are two
> different programs.
OK. Got it.

> Yes, but remember that while the child runs, the parent is parked
> inside a single DOS call--the call to Exec function that runs the
> child.  So, from the parent's point of view, only a single function
> call was done, and the data in the tb is supposed to be the same.
Uhm... I wouldn't assume that a call to write() doesen't change tb.
IMVHO it's not a good programming practice to assume that.

> It is the same as a single call to `_write': when `_write' returns,
> you'd expect to find the same data in the tb as what you put there.
Why ? Why should I SUSPECT that a tb in DOS memory is used ?
I pass to write() a buffer that can be everywhere in memory. Then
write() itself handles tb. I hope the user have NEVER to worry about
even the EXISTENCE of a tb in DOS memory. The passed buffer shouldn't be
altered without notice. tb is something 'for internal use only'. :-)

> Because nobody said it does.  Suppose you put something in a buffer.
> Would you expect the contents of the buffer to change under your feet,
> unless the docs says so?  tb is just another buffer.  It is documented
> to be overwritten by every system call, but not *inside* system calls.
That's true for the buffer pointed to by the pointer I pass to write().
Just an example. Suppose you have to write an 800K buffer to a file. You
can do it with a single call to write(), right ? Well, if I'm not
missing something, write() calls multiple times DOS services, filling
multiple times the tb with different data. So the tb is altered more
than once with a single call...

> Of course, you could save and restore the contents of tb, but that's
> not how it works now.
It could be changed, if needed, right ? :-) That should need no more
than 20 lines of code, or 2 function calls (saveTB and restoreTB).

- Raw text -


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