delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/03/25/08:49:32

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: <17B78BDF120BD411B70100500422FC6309E50F@IIS000>
From: Bernard Dautrevaux <Dautrevaux AT microprocess DOT com>
To: "'Stephane Corbe'" <sc AT axlog DOT fr>, cygwin AT cygwin DOT com
Cc: al AT axlog DOT fr
Subject: RE: Time sharing and fork
Date: Mon, 25 Mar 2002 14:46:39 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)

> -----Original Message-----
> From: Stephane Corbe [mailto:sc AT axlog DOT fr]
> Sent: Friday, March 22, 2002 4:55 PM
> To: cygwin AT cygwin DOT com
> Cc: al AT axlog DOT fr
> Subject: Re: Time sharing and fork
> 
> 
> 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 ...

And there's no bug either in the result you got :-)

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

So what is your problem?

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

Except that if the child (or the father) uses all available processor time,
then as long as it runs there is no time to left to the father. What an OS
tries to do here is to give you th emost effective result, that is the
shorter total execution time. It would switch only if it thinks it's
beneficial, i.e. for example if there is contention of the output, that is
if you write on a low speed output device: the chile write some, get
blocked, then the father start, the output drains during startup time (it's
probably handled in interruption), then th efather can output some before
being blocked, then the son restarts, etc. etc. ad nauseam :-)

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

Both are perfectly fitting the requirements written by your program: you
want some number of As *and* some number of Bs and do not give *any*
constraint regarding th eorder in which you want the As and Bs to get out.
If you *need* some constraints then you have to use synchronization
primitives...

HTH

        Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux AT microprocess DOT com
-------------------------------------------- 

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