sysvinit/startpar-0.50.dif

86 lines
2.0 KiB
Plaintext
Raw Normal View History

--- makeboot.c
+++ makeboot.c 2007-10-31 18:42:03.145266987 +0100
@@ -339,6 +339,10 @@ struct makenode *pickup_task(void)
best = node;
}
}
+ if (best) {
+ blogger("service %s", best->name);
+ best->status = T_RUNNING;
+ }
return best;
}
@@ -412,3 +416,36 @@ void dump_status(void)
node->name, node->status, node->num_deps, node->interactive, node->importance);
}
#endif
+
+#ifdef TEST
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *r;
+ if ((r = (void *)calloc(nmemb, size)) == 0) {
+ fprintf(stderr, "calloc: out of memory\n");
+ exit(1);
+ }
+ return r;
+}
+
+int main(int argc, char **argv)
+{
+ struct makenode *nodevec;
+ char makefile[64];
+
+ if (argc != 2)
+ goto out;
+ nodevec = xcalloc(1, sizeof(*nodevec));
+
+ snprintf(makefile, sizeof(makefile), "depend.%s", argv[1]);
+ parse_makefile(makefile);
+ check_run_files(argv[1], "5", "6");
+out:
+ while ((nodevec = pickup_task())) {
+ fprintf(stdout, "%s\n", nodevec->name);
+ finish_task(nodevec);
+ }
+
+ return 0;
+}
+#endif
--- startpar.c
+++ startpar.c 2007-10-31 17:49:27.179001593 +0100
@@ -72,7 +72,7 @@ struct prg {
static struct prg *prgs;
static int inpar, par;
static int pidpipe[2];
-static int iorate = 800;
+static double iorate = 800.0;
void *xcalloc(size_t nmemb, size_t size)
{
@@ -240,8 +240,8 @@ static int checksystem(const int par, co
if (read_proc(&prcs_run, &prcs_blked))
return par;
- newpar = (par*numcpu) - prcs_run + 1; /* +1 for startpar its self */
- newpar -= (prcs_blked * iorate); /* I/O load reduction */
+ newpar = (par*numcpu) - prcs_run + 1; /* +1 for startpar its self */
+ newpar -= (int)(((double)prcs_blked)*iorate); /* I/O load reduction */
#if DEBUG
fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%u) %ld\n", par, newpar, prcs_run, time(0));
@@ -573,9 +573,9 @@ int main(int argc, char **argv)
usage(0);
break;
case 'i':
- iorate = atoi(optarg);
- if (iorate <= 0)
- iorate = 800;
+ iorate = atof(optarg);
+ if (iorate < 0.0)
+ iorate = 800.0;
break;
default:
usage(1);