delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/14/06:38:17

Sender: crough45 AT amc DOT de
Date: Mon, 14 Apr 1997 11:27:32 +0100
From: Chris Croughton <crough45 AT amc DOT de>
Mime-Version: 1.0
To: eliz AT is DOT elta DOT co DOT il
Cc: djgpp AT delorie DOT com
Subject: Re: Multitasking in DJGP
Message-Id: <97Apr14.122452gmt+0100.21890@internet01.amc.de>

Eli Zaretskii wrote:

>I don't understand.  This is exactly what `spawnXX' function do right
>now.  If you are willing to suspend the parent until the child exits,
>why do you need `fork' at all?

'spawnxx' runs a different program, 'fork' runs a thread in the same 
program (well, sort-of).  Take the following code:

main()
{
  if (fork())
  {
    printf("Hello ");
  }
  else
  {
    printf("World!");
  }
}

The bit which prints "Hello" is the child, but it isn't a separate
program it's part of the same one.  I don't mind whether the child
finishes before the parent continues (which it might even in a true
multitasking environment), I do want it to run in the same program
as the parent.

(OK, on a real multiitasking system the data spaces would be separate,
but the code spaces still wouldn't be).

In tcsh, for example, the 'child' part of the fork /may/ do an exec
to run another program, in which case it could be replaced by spawn, 
but it may not, it could do an internal function as the action.

The misunderstanding, I suspect, is because I was using the term 'child'
in the Unix sense and you read it in the DOS one.  Or Maybe Not.

Chris

- Raw text -


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