Add code to enforce the paralleism count (-j N) for the entire tree
authorMax Okumoto <okumoto@dragonflybsd.org>
Fri, 10 Dec 2004 01:16:25 +0000 (01:16 +0000)
committerMax Okumoto <okumoto@dragonflybsd.org>
Fri, 10 Dec 2004 01:16:25 +0000 (01:16 +0000)
commitaa582f6446a74072cf1e2ed9ec6d76ab64e6242a
tree27b66b4fbd882ba24286849d2996113695b314bb
parentb43288f377d5c30e8ede9f2f3b7d77f469efd8eb
Add code to enforce the paralleism count (-j N) for the entire tree
of submakes spawned during processing.

We create a fifo and stuff one character into it for each job we are
allowed to run.  The name of the fifo is passed to child processes
in the MAKE_JOBS_FIFO environment variable.

A make which finds this variable on startup will open the fifo and
only spawn jobs when it managed to read a token from the fifo.
When the job completes a token is writen back to the fifo.

Slave make processes get one token for free: the one their parent
make got in order to run them.  This makes the make processes
themselves invisible in the process counts.

The net effect is that "make -j 12 -s buildworld" will start at
most 12 jobs at the same time, instead of as previously up to
65 jobs would get started.

Taken-from: FreeBSD
Author: phk
usr.bin/make/job.c
usr.bin/make/job.h
usr.bin/make/main.c
usr.bin/make/make.c