This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Time sharing and fork



> -----Original Message-----
> From: Stephane Corbe [mailto:sc@axlog.fr]
> Sent: Friday, March 22, 2002 4:55 PM
> To: cygwin@cygwin.com
> Cc: al@axlog.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@microprocess.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]