Changeset 153 for branches/GNU/src/gmake/job.c
- Timestamp:
- Sep 8, 2004, 4:43:30 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gmake/job.c
r54 r153 55 55 #elif defined (__EMX__) 56 56 57 c onst char *default_shell = "/bin/sh";57 char *default_shell = "/bin/sh"; 58 58 int batch_mode_shell = 0; 59 59 … … 223 223 224 224 int unixy_shell = 1; 225 226 /* Number of jobs started in the current second. */ 227 228 unsigned long job_counter = 0; 225 229 226 230 … … 363 367 364 368 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 */ 369 372 370 373 static char * 371 handle_apos (char *p)374 vms_handle_apos (char *p) 372 375 { 373 376 int alast; 374 int inside;375 377 376 378 #define SEPCHARS ",/()= " 377 379 378 inside= 0;380 alast = 0; 379 381 380 382 while (*p != 0) … … 382 384 if (*p == '"') 383 385 { 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++; 399 390 } 400 391 else … … 403 394 if (strchr (SEPCHARS, *p)) 404 395 break; 405 inside = 1;406 396 alast = 1; 407 while (*p == '"')408 {409 alast++;410 p++;411 }412 397 } 413 398 } … … 434 419 static unsigned int dead_children = 0; 435 420 436 #ifndef __EMX__ /* Don't use SIGCHLD handler on OS/2. */437 421 RETSIGTYPE 438 child_handler (int sig )422 child_handler (int sig UNUSED) 439 423 { 440 424 ++dead_children; … … 446 430 } 447 431 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(). 448 438 DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children)); 439 */ 449 440 } 450 #endif /* !__EMX__ */451 441 452 442 extern int shell_function_pid, shell_function_completed; … … 579 569 coredump = WCOREDUMP (status); 580 570 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; 592 574 } 593 575 else … … 899 881 900 882 #ifdef MAKE_JOBSERVER 901 # ifdef __EMX__902 /* Never install the SIGCHLD handler for EMX!!! */903 # define set_child_handler_action_flags(x)904 # else905 883 /* Set the child handler action flags to FLAGS. */ 906 884 static void … … 918 896 #endif 919 897 } 920 #endif /* !__EMX__ */921 898 #endif 922 899 … … 1357 1334 #endif /* __MSDOS__ or Amiga or WINDOWS32 */ 1358 1335 1336 /* Bump the number of jobs started in this second. */ 1337 ++job_counter; 1338 1359 1339 /* We are the parent side. Set the state to 1360 1340 say the commands are running and return. */ … … 1645 1625 got_token = read (job_rfd, &token, 1); 1646 1626 saved_errno = errno; 1627 #ifdef __EMX__ 1628 /* The child handler must be turned off here. */ 1629 signal (SIGCHLD, SIG_DFL); 1630 #endif 1647 1631 set_child_handler_action_flags (SA_RESTART); 1648 1632 … … 1701 1685 } 1702 1686 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 1703 1727 static int 1704 1728 load_too_high (void) … … 1707 1731 return 1; 1708 1732 #else 1709 double load; 1733 static double last_sec; 1734 static time_t last_now; 1735 double load, guess; 1736 time_t now; 1710 1737 1711 1738 if (max_load_average < 0) 1712 1739 return 0; 1713 1740 1741 /* Find the real system load average. */ 1714 1742 make_access (); 1715 1743 if (getloadavg (&load, 1) != 1) … … 1731 1759 user_access (); 1732 1760 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; 1736 1782 #endif 1737 1783 } … … 2169 2215 comma or space and before slash. */ 2170 2216 case '"': 2171 q = handle_apos (q + 1);2217 q = vms_handle_apos (q); 2172 2218 sep = q; 2173 2219 break; … … 2706 2752 char** sh_cmds; 2707 2753 #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 2715 2761 register int i; 2716 2762 register char *p;
Note:
See TracChangeset
for help on using the changeset viewer.