aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2009-10-24 18:53:59 +0000
committerDimitri Sokolyuk <demon@dim13.org>2009-10-24 18:53:59 +0000
commit486179e39baea48095e3f75529451ccb6b8e5321 (patch)
treeb630c05d2ff74cc026e22859f72a1562a4906ebb
parent31ec0915a17920cc9c4e3865d19536f5e856fd74 (diff)
move mutex otside of loop
-rw-r--r--weasel.c4
1 files 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;
}