From 486179e39baea48095e3f75529451ccb6b8e5321 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 24 Oct 2009 18:53:59 +0000 Subject: move mutex otside of loop --- weasel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weasel.c b/weasel.c index f683d70..07527b5 100644 --- a/weasel.c +++ b/weasel.c @@ -140,15 +140,15 @@ pickrandom() { int hasone = 0; + pthread_mutex_lock(&mutexsum); while (!hasone) { - pthread_mutex_lock(&mutexsum); cp = generation[random() % population]; if (!cp->locked) { cp->locked = 1; hasone = 1; } - pthread_mutex_unlock(&mutexsum); } + pthread_mutex_unlock(&mutexsum); return cp; } -- cgit v1.2.3