[Top][All Lists]

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

Re: How does '-j' switch work

From: Paul D. Smith
Subject: Re: How does '-j' switch work
Date: Wed, 20 Apr 2005 13:56:24 -0400

%% haynes george <address@hidden> writes:

  hg> It CANNOT be just

  hg> 1)Create a dependency graph
  hg> 2)Do a topological sort
  hg> 3)Now traverse thru the sorted list and do fork && exec

Make never sorts targets: the order in which targets are specified in
the makefile is encoded into the graph, and this order is significant so
sorting the nodes into some other order would break things.

  hg> Does it use threads by any means???

No.  Make uses, essentially, asyncronous programming to avoid the
requirement for threading.

Remember make doesn't actually COMPILE stuff.  It just invokes the
compiler, then (in serial mode) waits for the compiler to finish.  The
amount of time make spends walking the dependency graph is MINISCULE
compared to the amount of time each command takes to run.

In parallel mode, make doesn't wait for the command to finish: it lets
the command it invoked run in the background and looks to see if there's
anything else to be built, that doesn't depend on anything which is
currently "in progress".

If there's nothing else that could be built, make waits for one of the
"in progress" commands to complete.

If there is something else to do, make tries to run that command.  If,
when it starts to run the command, it sees that all the jobs its allowed
to run are currently running, it waits for something to finish (this is
if you use -jN; if you use -j with no maximum obviously this clause is
not relevant).

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "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]