There is no need to count jobs and job tokens.
If we don't create the job pipe, use the '-j n' option to limit the number of tokens we will remove from the pipe.
This commit is contained in:
parent
ec5cc02622
commit
33369a0245
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.c,v 1.110 2006/03/15 20:33:19 dsl Exp $ */
|
||||
/* $NetBSD: job.c,v 1.111 2006/03/31 21:05:34 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -70,14 +70,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.110 2006/03/15 20:33:19 dsl Exp $";
|
||||
static char rcsid[] = "$NetBSD: job.c,v 1.111 2006/03/31 21:05:34 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: job.c,v 1.110 2006/03/15 20:33:19 dsl Exp $");
|
||||
__RCSID("$NetBSD: job.c,v 1.111 2006/03/31 21:05:34 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -112,9 +112,6 @@ __RCSID("$NetBSD: job.c,v 1.110 2006/03/15 20:33:19 dsl Exp $");
|
||||
*
|
||||
* Job_End Cleanup any memory used.
|
||||
*
|
||||
* Job_Empty Return TRUE if the job table is completely
|
||||
* empty.
|
||||
*
|
||||
* Job_ParseShell Given the line following a .SHELL target, parse
|
||||
* the line as a shell specification. Returns
|
||||
* FAILURE if the spec was incorrect.
|
||||
@ -267,7 +264,6 @@ const char *shellPath = NULL, /* full pathname of
|
||||
static const char *shellArgv = NULL; /* Custom shell args */
|
||||
|
||||
|
||||
static int maxJobs; /* The most children we can run at once */
|
||||
STATIC Lst jobs; /* The structures that describe them */
|
||||
static Boolean wantToken; /* we want a token */
|
||||
|
||||
@ -386,8 +382,7 @@ static void JobSigUnlock(sigset_t *omaskp)
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* JobCondPassSig --
|
||||
* Pass a signal to a job if the job is remote or if USE_PGRP
|
||||
* is defined.
|
||||
* Pass a signal to a job if USE_PGRP is defined.
|
||||
*
|
||||
* Input:
|
||||
* jobp Job to biff
|
||||
@ -468,8 +463,8 @@ JobContinueSig(int signo __unused)
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* JobPassSig --
|
||||
* Pass a signal on to all remote jobs and to all local jobs if
|
||||
* USE_PGRP is defined, then die ourselves.
|
||||
* Pass a signal on to all local jobs if
|
||||
* USE_PGRP is defined, then resend to ourselves.
|
||||
*
|
||||
* Input:
|
||||
* signo The signal number we've received
|
||||
@ -1078,7 +1073,6 @@ JobFinish(Job *job, int *status)
|
||||
errors += 1;
|
||||
free(job);
|
||||
}
|
||||
JobRestartJobs();
|
||||
|
||||
/*
|
||||
* Set aborting if any error.
|
||||
@ -1095,7 +1089,7 @@ JobFinish(Job *job, int *status)
|
||||
if (return_job_token)
|
||||
Job_TokenReturn();
|
||||
|
||||
if ((aborting == ABORT_ERROR) && Job_Empty()) {
|
||||
if (aborting == ABORT_ERROR && jobTokensRunning == 0) {
|
||||
/*
|
||||
* If we are aborting and the job table is now empty, we finish.
|
||||
*/
|
||||
@ -2198,10 +2192,6 @@ Shell_Init()
|
||||
* Initialize the process module
|
||||
*
|
||||
* Input:
|
||||
* maxproc the greatest number of jobs which may be running
|
||||
* at one time
|
||||
* maxlocal the greatest number of jobs which may be running
|
||||
* at once
|
||||
*
|
||||
* Results:
|
||||
* none
|
||||
@ -2211,13 +2201,12 @@ Shell_Init()
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Job_Init(int maxproc)
|
||||
Job_Init(void)
|
||||
{
|
||||
GNode *begin; /* node for commands to do at the very start */
|
||||
|
||||
jobs = Lst_Init(FALSE);
|
||||
stoppedJobs = Lst_Init(FALSE);
|
||||
maxJobs = maxproc;
|
||||
wantToken = FALSE;
|
||||
|
||||
aborting = 0;
|
||||
@ -2315,39 +2304,6 @@ static void JobSigReset(void)
|
||||
(void)signal(SIGCHLD, SIG_DFL);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Job_Empty --
|
||||
* See if the job table is empty. Because the local concurrency may
|
||||
* be set to 0, it is possible for the job table to become empty,
|
||||
* while the list of stoppedJobs remains non-empty. In such a case,
|
||||
* we want to restart as many jobs as we can.
|
||||
*
|
||||
* Results:
|
||||
* TRUE if it is. FALSE if it ain't.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
* -----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Job_Empty(void)
|
||||
{
|
||||
if (jobTokensRunning != 0)
|
||||
return FALSE;
|
||||
|
||||
if (Lst_IsEmpty(stoppedJobs) || aborting)
|
||||
return TRUE;
|
||||
|
||||
/*
|
||||
* The job table is obviously not full if it has no jobs in
|
||||
* it...Try and restart the stopped jobs.
|
||||
*/
|
||||
JobRestartJobs();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* JobMatchShell --
|
||||
@ -2882,7 +2838,7 @@ JobTokenAdd(void)
|
||||
*/
|
||||
|
||||
void
|
||||
Job_ServerStart(int maxproc)
|
||||
Job_ServerStart(void)
|
||||
{
|
||||
int i, fd, flags;
|
||||
char jobarg[64];
|
||||
@ -2925,11 +2881,11 @@ Job_ServerStart(int maxproc)
|
||||
* Preload job_pipe with one token per job, save the one
|
||||
* "extra" token for the primary job.
|
||||
*
|
||||
* XXX should clip maxJobs against PIPE_BUF -- if maxJobs is
|
||||
* XXX should clip maxJobs against PIPE_BUF -- if maxJobTokens is
|
||||
* larger than the write buffer size of the pipe, we will
|
||||
* deadlock here.
|
||||
*/
|
||||
for (i=1; i < maxproc; i++)
|
||||
for (i=1; i < maxJobTokens; i++)
|
||||
JobTokenAdd();
|
||||
}
|
||||
|
||||
@ -2979,7 +2935,7 @@ Job_TokenWithdraw(void)
|
||||
printf("Job_TokenWithdraw(%d): aborting %d, running %d\n",
|
||||
getpid(), aborting, jobTokensRunning);
|
||||
|
||||
if (aborting || (jobTokensRunning && not_parallel))
|
||||
if (aborting || (jobTokensRunning >= maxJobs))
|
||||
return FALSE;
|
||||
|
||||
count = read(job_pipe[0], &tok, 1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: job.h,v 1.26 2006/03/13 20:35:09 dsl Exp $ */
|
||||
/* $NetBSD: job.h,v 1.27 2006/03/31 21:05:34 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
@ -264,7 +264,8 @@ extern const char *shellName;
|
||||
|
||||
extern int job_pipe[2]; /* token pipe for jobs. */
|
||||
extern int jobTokensRunning; /* tokens currently "out" */
|
||||
extern int not_parallel; /* => only run one job */
|
||||
extern int maxJobs; /* Max jobs we can run */
|
||||
extern int maxJobTokens; /* Number of token for the job pipe */
|
||||
|
||||
void Shell_Init(void);
|
||||
void Job_Touch(GNode *, Boolean);
|
||||
@ -272,7 +273,7 @@ Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...));
|
||||
void Job_CatchChildren(Boolean);
|
||||
void Job_CatchOutput(void);
|
||||
void Job_Make(GNode *);
|
||||
void Job_Init(int);
|
||||
void Job_Init(void);
|
||||
Boolean Job_Full(void);
|
||||
Boolean Job_Empty(void);
|
||||
ReturnStatus Job_ParseShell(char *);
|
||||
@ -283,6 +284,6 @@ void Job_AbortAll(void);
|
||||
void JobFlagForMigration(int);
|
||||
void Job_TokenReturn(void);
|
||||
Boolean Job_TokenWithdraw(void);
|
||||
void Job_ServerStart(int);
|
||||
void Job_ServerStart(void);
|
||||
|
||||
#endif /* _JOB_H_ */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.122 2006/03/17 15:39:44 christos Exp $ */
|
||||
/* $NetBSD: main.c,v 1.123 2006/03/31 21:05:34 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.122 2006/03/17 15:39:44 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: main.c,v 1.123 2006/03/31 21:05:34 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.122 2006/03/17 15:39:44 christos Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.123 2006/03/31 21:05:34 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -156,6 +156,7 @@ static Lst makefiles; /* ordered list of makefiles to read */
|
||||
static Boolean printVars; /* print value of one or more vars */
|
||||
static Lst variables; /* list of variables to print */
|
||||
int maxJobs; /* -j argument */
|
||||
int maxJobTokens; /* -j argument */
|
||||
Boolean compatMake; /* -B argument */
|
||||
int debug; /* -d argument */
|
||||
Boolean noExecute; /* -n flag */
|
||||
@ -427,6 +428,7 @@ rearg:
|
||||
}
|
||||
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
maxJobTokens = maxJobs;
|
||||
break;
|
||||
case 'k':
|
||||
keepgoing = TRUE;
|
||||
@ -782,6 +784,7 @@ main(int argc, char **argv)
|
||||
jobsRunning = FALSE;
|
||||
|
||||
maxJobs = DEFMAXLOCAL; /* Set default local max concurrency */
|
||||
maxJobTokens = maxJobs;
|
||||
compatMake = FALSE; /* No compat mode */
|
||||
|
||||
|
||||
@ -925,10 +928,10 @@ main(int argc, char **argv)
|
||||
free(p1);
|
||||
|
||||
if (!jobServer && !compatMake)
|
||||
Job_ServerStart(maxJobs);
|
||||
Job_ServerStart();
|
||||
if (DEBUG(JOB))
|
||||
printf("job_pipe %d %d, maxjobs %d compat %d\n",
|
||||
job_pipe[0], job_pipe[1], maxJobs, compatMake);
|
||||
printf("job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n",
|
||||
job_pipe[0], job_pipe[1], maxJobs, maxJobTokens, compatMake);
|
||||
|
||||
Main_ExportMAKEFLAGS(TRUE); /* initial export */
|
||||
|
||||
@ -1022,7 +1025,7 @@ main(int argc, char **argv)
|
||||
* being executed should it exist).
|
||||
*/
|
||||
if (!queryFlag) {
|
||||
Job_Init(maxJobs);
|
||||
Job_Init();
|
||||
jobsRunning = TRUE;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: make.c,v 1.61 2006/02/11 20:59:49 dsl Exp $ */
|
||||
/* $NetBSD: make.c,v 1.62 2006/03/31 21:05:34 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: make.c,v 1.61 2006/02/11 20:59:49 dsl Exp $";
|
||||
static char rcsid[] = "$NetBSD: make.c,v 1.62 2006/03/31 21:05:34 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: make.c,v 1.61 2006/02/11 20:59:49 dsl Exp $");
|
||||
__RCSID("$NetBSD: make.c,v 1.62 2006/03/31 21:05:34 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -1228,7 +1228,7 @@ Make_Run(Lst targs)
|
||||
* Note that the Job module will exit if there were any errors unless the
|
||||
* keepgoing flag was given.
|
||||
*/
|
||||
while (!Lst_IsEmpty(toBeMade) || !Job_Empty ()) {
|
||||
while (!Lst_IsEmpty(toBeMade) || jobTokensRunning > 0) {
|
||||
Job_CatchOutput();
|
||||
Job_CatchChildren(!usePipes);
|
||||
(void)MakeStartJobs();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.112 2006/03/31 20:30:46 christos Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.113 2006/03/31 21:05:34 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -69,14 +69,14 @@
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.112 2006/03/31 20:30:46 christos Exp $";
|
||||
static char rcsid[] = "$NetBSD: parse.c,v 1.113 2006/03/31 21:05:34 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.112 2006/03/31 20:30:46 christos Exp $");
|
||||
__RCSID("$NetBSD: parse.c,v 1.113 2006/03/31 21:05:34 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
@ -1127,7 +1127,7 @@ ParseDoDependency(char *line)
|
||||
DEFAULT = gn;
|
||||
break;
|
||||
case NotParallel:
|
||||
not_parallel = 1;
|
||||
maxJobs = 1;
|
||||
break;
|
||||
case SingleShell:
|
||||
compatMake = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user