Changeset 160 for trunk/src/gmake/job.c
- Timestamp:
- Sep 8, 2004, 5:15:50 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/job.c
r58 r160 230 230 231 231 int unixy_shell = 1; 232 233 /* Number of jobs started in the current second. */ 234 235 unsigned long job_counter = 0; 232 236 233 237 … … 370 374 371 375 372 /* 373 found apostrophe at (p-1) 374 375 inc p until after closing apostrophe. */ 376 /* found apostrophe at (p-1) 377 inc p until after closing apostrophe. 378 */ 376 379 377 380 static char * 378 handle_apos (char *p)381 vms_handle_apos (char *p) 379 382 { 380 383 int alast; 381 int inside;382 384 383 385 #define SEPCHARS ",/()= " 384 386 385 inside= 0;387 alast = 0; 386 388 387 389 while (*p != 0) … … 389 391 if (*p == '"') 390 392 { 391 if (inside) 392 { 393 while ((alast > 0) 394 && (*p == '"')) 395 { 396 p++; 397 alast--; 398 } 399 if (alast == 0) 400 inside = 0; 401 else 402 { 403 fprintf (stderr, _("Syntax error, still inside '\"'\n")); 404 exit (3); 405 } 393 if (alast) 394 { 395 alast = 0; 396 p++; 406 397 } 407 398 else … … 410 401 if (strchr (SEPCHARS, *p)) 411 402 break; 412 inside = 1;413 403 alast = 1; 414 while (*p == '"')415 {416 alast++;417 p++;418 }419 404 } 420 405 } … … 442 427 443 428 RETSIGTYPE 444 child_handler (int sig )429 child_handler (int sig UNUSED) 445 430 { 446 431 ++dead_children; … … 453 438 454 439 #ifdef __EMX__ 455 signal(SIGCHLD, SIG_DFL); /* The signal handler must called only once! ????*/ 456 #endif 457 440 /* The signal handler must called only once! */ 441 signal (SIGCHLD, SIG_DFL); 442 #endif 443 444 /* This causes problems if the SIGCHLD interrupts a printf(). 458 445 DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children)); 446 */ 459 447 } 460 448 … … 605 593 coredump = WCOREDUMP (status); 606 594 607 #if 0 /*def __EMX__*/ 608 /* the SIGCHLD handler must not be used on OS/2 because, unlike 609 on UNIX systems, it had to call wait() itself. Therefore 610 job_rfd has to be closed here. */ 611 if (job_rfd >= 0) 612 { 613 close (job_rfd); 614 job_rfd = -1; 615 } 616 #endif 617 595 /* If we have started jobs in this second, remove one. */ 596 if (job_counter) 597 --job_counter; 618 598 } 619 599 else … … 1378 1358 #endif /* __MSDOS__ or Amiga or WINDOWS32 */ 1379 1359 1360 /* Bump the number of jobs started in this second. */ 1361 ++job_counter; 1362 1380 1363 /* We are the parent side. Set the state to 1381 1364 say the commands are running and return. */ … … 1667 1650 saved_errno = errno; 1668 1651 #ifdef __EMX__ 1669 signal(SIGCHLD, SIG_DFL); /* The child handler must be turned off here. */ 1652 /* The child handler must be turned off here. */ 1653 signal (SIGCHLD, SIG_DFL); 1670 1654 #endif 1671 1655 set_child_handler_action_flags (SA_RESTART); … … 1725 1709 } 1726 1710 1711 /* Determine if the load average on the system is too high to start a new job. 1712 The real system load average is only recomputed once a second. However, a 1713 very parallel make can easily start tens or even hundreds of jobs in a 1714 second, which brings the system to its knees for a while until that first 1715 batch of jobs clears out. 1716 1717 To avoid this we use a weighted algorithm to try to account for jobs which 1718 have been started since the last second, and guess what the load average 1719 would be now if it were computed. 1720 1721 This algorithm was provided by Thomas Riedl <thomas.riedl@siemens.com>, 1722 who writes: 1723 1724 ! calculate something load-oid and add to the observed sys.load, 1725 ! so that latter can catch up: 1726 ! - every job started increases jobctr; 1727 ! - every dying job decreases a positive jobctr; 1728 ! - the jobctr value gets zeroed every change of seconds, 1729 ! after its value*weight_b is stored into the 'backlog' value last_sec 1730 ! - weight_a times the sum of jobctr and last_sec gets 1731 ! added to the observed sys.load. 1732 ! 1733 ! The two weights have been tried out on 24 and 48 proc. Sun Solaris-9 1734 ! machines, using a several-thousand-jobs-mix of cpp, cc, cxx and smallish 1735 ! sub-shelled commands (rm, echo, sed...) for tests. 1736 ! lowering the 'direct influence' factor weight_a (e.g. to 0.1) 1737 ! resulted in significant excession of the load limit, raising it 1738 ! (e.g. to 0.5) took bad to small, fast-executing jobs and didn't 1739 ! reach the limit in most test cases. 1740 ! 1741 ! lowering the 'history influence' weight_b (e.g. to 0.1) resulted in 1742 ! exceeding the limit for longer-running stuff (compile jobs in 1743 ! the .5 to 1.5 sec. range),raising it (e.g. to 0.5) overrepresented 1744 ! small jobs' effects. 1745 1746 */ 1747 1748 #define LOAD_WEIGHT_A 0.25 1749 #define LOAD_WEIGHT_B 0.25 1750 1727 1751 static int 1728 1752 load_too_high (void) … … 1731 1755 return 1; 1732 1756 #else 1733 double load; 1757 static double last_sec; 1758 static time_t last_now; 1759 double load, guess; 1760 time_t now; 1734 1761 1735 1762 if (max_load_average < 0) 1736 1763 return 0; 1737 1764 1765 /* Find the real system load average. */ 1738 1766 make_access (); 1739 1767 if (getloadavg (&load, 1) != 1) … … 1755 1783 user_access (); 1756 1784 1757 DB (DB_JOBS, ("Current system load = %f (max requested = %f)\n", 1758 load, max_load_average)); 1759 return load >= max_load_average; 1785 /* If we're in a new second zero the counter and correct the backlog 1786 value. Only keep the backlog for one extra second; after that it's 0. */ 1787 now = time (NULL); 1788 if (last_now < now) 1789 { 1790 if (last_now == now - 1) 1791 last_sec = LOAD_WEIGHT_B * job_counter; 1792 else 1793 last_sec = 0.0; 1794 1795 job_counter = 0; 1796 last_now = now; 1797 } 1798 1799 /* Try to guess what the load would be right now. */ 1800 guess = load + (LOAD_WEIGHT_A * (job_counter + last_sec)); 1801 1802 DB (DB_JOBS, ("Estimated system load = %f (actual = %f) (max requested = %f)\n", 1803 guess, load, max_load_average)); 1804 1805 return guess >= max_load_average; 1760 1806 #endif 1761 1807 } … … 2193 2239 comma or space and before slash. */ 2194 2240 case '"': 2195 q = handle_apos (q + 1);2241 q = vms_handle_apos (q); 2196 2242 sep = q; 2197 2243 break; … … 2868 2914 char** sh_cmds; 2869 2915 #else /* must be UNIX-ish */ 2870 static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~ ";2871 static char *sh_cmds[] = { " cd", "eval", "exec", "exit", "login",2872 "logout", "set", "umask", "wait", "while", "for",2873 "case", "if", ":", ".", "break", "continue",2874 "export", "read", "readonly", "shift", "times",2875 "trap", "switch", 0 };2876 #endif /* __MSDOS__ */2916 static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!"; 2917 static char *sh_cmds[] = { ".", ":", "break", "case", "cd", "continue", 2918 "eval", "exec", "exit", "export", "for", "if", 2919 "login", "logout", "read", "readonly", "set", 2920 "shift", "switch", "test", "times", "trap", 2921 "umask", "wait", "while", 0 }; 2922 #endif 2877 2923 register int i; 2878 2924 register char *p;
Note:
See TracChangeset
for help on using the changeset viewer.