delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/22/10:12:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3C9B53DB.8F741D81@axlog.fr>
Date: Fri, 22 Mar 2002 15:55:08 +0000
From: Stephane Corbe <sc AT axlog DOT fr>
X-Mailer: Mozilla 4.7 [en] (X11; I; SunOS 5.8 sun4u)
X-Accept-Language: fr, en
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Cc: al AT axlog DOT fr
Subject: Re: Time sharing and fork
References: <FC169E059D1A0442A04C40F86D9BA76008AB5B AT itdomain003 DOT itdomain DOT net DOT au> <3C9B1A4D DOT 32EE2167 AT axlog DOT fr> <3C9B287F DOT 8E69BB6C AT axlog DOT fr> <20020322142708 DOT GE20338 AT redhat DOT com>

Christopher Faylor wrote:

> That's not guaranteed fork behavior.  If the child never started, that would
> be a bug.

As you can see in my previous post, the programm is really simple :
a loop of printf for the child, a loop of printf for the father.
There's no place for a bug here ...

>  There is no guaranteed behavior with respect to which process is
> scheduled after a fork on windows or linux.  If you want to serialize things
> use one of the wait calls.

I don't want serialized anything, I don't expect that the child or the father
start at first.

Just I wish that the child share the time (the cpu) with his father.

On solaris the two processes run like that :
(A is some printf from father, B is some printf from child)

ABABABABABABA(end of A)B(end of B)

On cygwin I have this result :

AAAAAAA(end of A)BBBBBBB(end of B)

Please read again (try?) this really simple programm :

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
  int probe_pid, i;

    printf("before fork\n");
    probe_pid = fork();
    printf("after fork %d\n", probe_pid);
    switch (probe_pid)
        {
        case 0 :

        for (i=0; i<10000; i++)
        {
          printf("%d> Je suis le fils %d\n", probe_pid, i);
        }
        break;

        case -1 :
          printf ("Erreur fork\n");
          exit(-1);
          break;

        default:

        for (i=0; i<10000; i++)
        {
          printf("%d> Je suis le pere %d\n", probe_pid, i);
        }
        break;
        }
    return 0;
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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