From 88030754dbe0f55deed90428e4c71f8ecf8d3bc3 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 5 Oct 2009 02:14:54 +0000 Subject: fix number of threads --- weasel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weasel.c b/weasel.c index a3f5254..0dd341f 100644 --- a/weasel.c +++ b/weasel.c @@ -225,7 +225,7 @@ main(int argc, char **argv) extern int LINES; int population = 1000; int mutationrate = 100; /* 1/n */ - int nthreads = population / 10; + int nthreads; int i, c, t; while ((c = getopt(argc, argv, "m:p:t:")) != -1) @@ -267,6 +267,9 @@ main(int argc, char **argv) args.population = population; args.mutationrate = mutationrate; + nthreads = population / 10; + if (!nthreads) + nthreads = 1; threads = calloc(nthreads, sizeof(pthread_t)); assert(threads); pthread_mutex_init(&mutexsum, NULL); -- cgit v1.2.3