delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/22/05:50:45

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: <3C9B1A4D.32EE2167@axlog.fr>
Date: Fri, 22 Mar 2002 11:49:33 +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: Time sharing and fork
References: <FC169E059D1A0442A04C40F86D9BA76008AB5B AT itdomain003 DOT itdomain DOT net DOT au>

Hello,

    Because my problems with fork and DLL continue, I tried to remove
DLL and to test only fork.
And Cygwin had a really different behavior than unix has.

With the programm below I have 1000 times "Je suis le fils" and then
10000 times "Je suis le pere" or the reverse sometimes.
Under my solaris the sentence switch after about 800 outputs. (See the
output traces at the end of mail)

I tried sched_setsched function too, (for SCHED_OTHER) but they seems
not implemented.

Is there a way to set the priority of the fork processes ???

    Stephane


#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;
}


Output : (On Cygwin 1.3.10-1 NT4)

before fork
after fork 343
343> Je suis le pere 0
343> Je suis le pere 1
...
9999> Je suis le pere 9999
after fork 0      <----------- See where the child begins
0> Je suis le fils 0
0> Je suis le fils 1
...
9999> Je suis le fils 9999


--
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