[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent behaviour when building in parallel

From: Paul Smith
Subject: Re: Inconsistent behaviour when building in parallel
Date: Sat, 20 Jan 2007 14:49:50 -0500

On Sat, 2007-01-20 at 17:35 +0100, Dirk Heinrichs wrote:

> So if make behaves correctly in the parallel case, does this mean that the 
> non-parallel case is wrong?


No, both are correct.

In the non-parallel case, make examines the first target and its
prerequisites and sees that it needs to be rebuilt, so it runs the rule.
The rule updates the first target and also updates the other targets.

Next make looks at the second target and its prerequisites and sees that
it does NOT need to be rebuilt (because it is newer than all the
prerequisites, since it was just updated).  So it's not rebuilt.  Etc.

In the parallel case, make does exactly the same thing EXCEPT that
instead of waiting for the first command to complete it immediately
checks the second target and, since the first command is not done yet
and hasn't updated it, make sees that it's still out of date so it runs
that rule again to update it.

In the parallel case you can't tell exactly what will happen: it depends
on your system; how busy it is, what order the various jobs are
scheduled by the OS, how long the command takes to execute, etc.  It
could work perfectly, or it could be run twice, or more times (if there
are more than two targets).

 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

[Prev in Thread] Current Thread [Next in Thread]