aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weasel.c5
1 files changed, 4 insertions, 1 deletions
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);