Ignore:
Timestamp:
Sep 8, 2004, 4:43:30 AM (21 years ago)
Author:
bird
Message:

GNU Make 3.81beta1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gmake/job.c

    r54 r153  
    5555#elif defined (__EMX__)
    5656
    57 const char *default_shell = "/bin/sh";
     57char *default_shell = "/bin/sh";
    5858int batch_mode_shell = 0;
    5959
     
    223223
    224224int unixy_shell = 1;
     225
     226/* Number of jobs started in the current second.  */
     227
     228unsigned long job_counter = 0;
    225229
    226230
     
    363367
    364368
    365 /*
    366    found apostrophe at (p-1)
    367 
    368    inc p until after closing apostrophe.  */
     369/* found apostrophe at (p-1)
     370   inc p until after closing apostrophe.
     371 */
    369372
    370373static char *
    371 handle_apos (char *p)
     374vms_handle_apos (char *p)
    372375{
    373376  int alast;
    374   int inside;
    375377
    376378#define SEPCHARS ",/()= "
    377379
    378   inside = 0;
     380  alast = 0;
    379381
    380382  while (*p != 0)
     
    382384      if (*p == '"')
    383385        {
    384           if (inside)
    385             {
    386               while ((alast > 0)
    387                     && (*p == '"'))
    388                 {
    389                   p++;
    390                   alast--;
    391                 }
    392               if (alast == 0)
    393                 inside = 0;
    394               else
    395                 {
    396                   fprintf (stderr, _("Syntax error, still inside '\"'\n"));
    397                   exit (3);
    398                 }
     386          if (alast)
     387            {
     388              alast = 0;
     389              p++;
    399390            }
    400391          else
     
    403394              if (strchr (SEPCHARS, *p))
    404395                break;
    405               inside = 1;
    406396              alast = 1;
    407               while (*p == '"')
    408                 {
    409                   alast++;
    410                   p++;
    411                 }
    412397            }
    413398        }
     
    434419static unsigned int dead_children = 0;
    435420
    436 #ifndef __EMX__ /* Don't use SIGCHLD handler on OS/2. */
    437421RETSIGTYPE
    438 child_handler (int sig)
     422child_handler (int sig UNUSED)
    439423{
    440424  ++dead_children;
     
    446430    }
    447431
     432#ifdef __EMX__
     433  /* The signal handler must called only once! */
     434  signal (SIGCHLD, SIG_DFL);
     435#endif
     436
     437  /* This causes problems if the SIGCHLD interrupts a printf().
    448438  DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children));
     439  */
    449440}
    450 #endif  /* !__EMX__ */
    451441
    452442extern int shell_function_pid, shell_function_completed;
     
    579569              coredump = WCOREDUMP (status);
    580570
    581 #ifdef __EMX__
    582               /* the SIGCHLD handler must not be used on OS/2 because, unlike
    583                  on UNIX systems, it had to call wait() itself.  Therefore
    584                  job_rfd has to be closed here.  */
    585               if (job_rfd >= 0)
    586                 {
    587                   close (job_rfd);
    588                   job_rfd = -1;
    589                 }
    590 #endif
    591 
     571              /* If we have started jobs in this second, remove one.  */
     572              if (job_counter)
     573                --job_counter;
    592574            }
    593575          else
     
    899881
    900882#ifdef MAKE_JOBSERVER
    901 # ifdef __EMX__
    902 /* Never install the SIGCHLD handler for EMX!!! */
    903 #  define set_child_handler_action_flags(x)
    904 # else
    905883/* Set the child handler action flags to FLAGS.  */
    906884static void
     
    918896#endif
    919897}
    920 #endif  /* !__EMX__ */
    921898#endif
    922899
     
    13571334#endif  /* __MSDOS__ or Amiga or WINDOWS32 */
    13581335
     1336  /* Bump the number of jobs started in this second.  */
     1337  ++job_counter;
     1338
    13591339  /* We are the parent side.  Set the state to
    13601340     say the commands are running and return.  */
     
    16451625        got_token = read (job_rfd, &token, 1);
    16461626        saved_errno = errno;
     1627#ifdef __EMX__
     1628        /* The child handler must be turned off here.  */
     1629        signal (SIGCHLD, SIG_DFL);
     1630#endif
    16471631        set_child_handler_action_flags (SA_RESTART);
    16481632
     
    17011685}
    17021686
     1687/* Determine if the load average on the system is too high to start a new job.
     1688   The real system load average is only recomputed once a second.  However, a
     1689   very parallel make can easily start tens or even hundreds of jobs in a
     1690   second, which brings the system to its knees for a while until that first
     1691   batch of jobs clears out.
     1692
     1693   To avoid this we use a weighted algorithm to try to account for jobs which
     1694   have been started since the last second, and guess what the load average
     1695   would be now if it were computed.
     1696
     1697   This algorithm was provided by Thomas Riedl <thomas.riedl@siemens.com>,
     1698   who writes:
     1699
     1700!      calculate something load-oid and add to the observed sys.load,
     1701!      so that latter can catch up:
     1702!      - every job started increases jobctr;
     1703!      - every dying job decreases a positive jobctr;
     1704!      - the jobctr value gets zeroed every change of seconds,
     1705!        after its value*weight_b is stored into the 'backlog' value last_sec
     1706!      - weight_a times the sum of jobctr and last_sec gets
     1707!        added to the observed sys.load.
     1708!
     1709!      The two weights have been tried out on 24 and 48 proc. Sun Solaris-9
     1710!      machines, using a several-thousand-jobs-mix of cpp, cc, cxx and smallish
     1711!      sub-shelled commands (rm, echo, sed...) for tests.
     1712!      lowering the 'direct influence' factor weight_a (e.g. to 0.1)
     1713!      resulted in significant excession of the load limit, raising it
     1714!      (e.g. to 0.5) took bad to small, fast-executing jobs and didn't
     1715!      reach the limit in most test cases.
     1716!
     1717!      lowering the 'history influence' weight_b (e.g. to 0.1) resulted in
     1718!      exceeding the limit for longer-running stuff (compile jobs in
     1719!      the .5 to 1.5 sec. range),raising it (e.g. to 0.5) overrepresented
     1720!      small jobs' effects.
     1721
     1722 */
     1723
     1724#define LOAD_WEIGHT_A           0.25
     1725#define LOAD_WEIGHT_B           0.25
     1726
    17031727static int
    17041728load_too_high (void)
     
    17071731  return 1;
    17081732#else
    1709   double load;
     1733  static double last_sec;
     1734  static time_t last_now;
     1735  double load, guess;
     1736  time_t now;
    17101737
    17111738  if (max_load_average < 0)
    17121739    return 0;
    17131740
     1741  /* Find the real system load average.  */
    17141742  make_access ();
    17151743  if (getloadavg (&load, 1) != 1)
     
    17311759  user_access ();
    17321760
    1733   DB (DB_JOBS, ("Current system load = %f (max requested = %f)\n",
    1734                 load, max_load_average));
    1735   return load >= max_load_average;
     1761  /* If we're in a new second zero the counter and correct the backlog
     1762     value.  Only keep the backlog for one extra second; after that it's 0.  */
     1763  now = time (NULL);
     1764  if (last_now < now)
     1765    {
     1766      if (last_now == now - 1)
     1767        last_sec = LOAD_WEIGHT_B * job_counter;
     1768      else
     1769        last_sec = 0.0;
     1770
     1771      job_counter = 0;
     1772      last_now = now;
     1773    }
     1774
     1775  /* Try to guess what the load would be right now.  */
     1776  guess = load + (LOAD_WEIGHT_A * (job_counter + last_sec));
     1777
     1778  DB (DB_JOBS, ("Estimated system load = %f (actual = %f) (max requested = %f)\n",
     1779                guess, load, max_load_average));
     1780
     1781  return guess >= max_load_average;
    17361782#endif
    17371783}
     
    21692215                 comma or space and before slash. */
    21702216            case '"':
    2171               q = handle_apos (q + 1);
     2217              q = vms_handle_apos (q);
    21722218              sep = q;
    21732219              break;
     
    27062752  char** sh_cmds;
    27072753#else  /* must be UNIX-ish */
    2708   static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~";
    2709   static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login",
    2710                              "logout", "set", "umask", "wait", "while", "for",
    2711                              "case", "if", ":", ".", "break", "continue",
    2712                              "export", "read", "readonly", "shift", "times",
    2713                              "trap", "switch", 0 };
    2714 #endif /* __MSDOS__ */
     2754  static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!";
     2755  static char *sh_cmds[] = { ".", ":", "break", "case", "cd", "continue",
     2756                             "eval", "exec", "exit", "export", "for", "if",
     2757                             "login", "logout", "read", "readonly", "set",
     2758                             "shift", "switch", "test", "times", "trap",
     2759                             "umask", "wait", "while", 0 };
     2760#endif
    27152761  register int i;
    27162762  register char *p;
Note: See TracChangeset for help on using the changeset viewer.