aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2009-10-05 02:14:54 +0000
committerDimitri Sokolyuk <demon@dim13.org>2009-10-05 02:14:54 +0000
commit88030754dbe0f55deed90428e4c71f8ecf8d3bc3 (patch)
tree41394661cd74f8a31d55ec29eb24970a3316af1f
parent7bdb09adb0575b38c3c73c86d24bafd1a96ff218 (diff)
fix number of threads
-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);