diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-02-20 04:43:50 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-02-20 04:43:50 +0000 |
commit | 5968dfdc76712582661cd15eaa2c6f592407c569 (patch) | |
tree | 58a1c3ddb5bd78926057e2e8d0da9094514d6499 /regress | |
parent | b3cb9a5bda3fef17dd3c98f1508457fbec58659f (diff) |
Round-robin behavior isn't guaranteed by SCHED_OTHER and the kernel
doesn't have SCHED_FIFO or SCHED_RR support, so use sleep(1) to 'ensure'
the second thread gets the lock when expected
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libpthread/pthread_mutex/pthread_mutex.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/regress/lib/libpthread/pthread_mutex/pthread_mutex.c b/regress/lib/libpthread/pthread_mutex/pthread_mutex.c index bae8f66c54e..a9de3c33e22 100644 --- a/regress/lib/libpthread/pthread_mutex/pthread_mutex.c +++ b/regress/lib/libpthread/pthread_mutex/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_mutex.c,v 1.7 2011/09/23 10:39:08 uwe Exp $ */ +/* $OpenBSD: pthread_mutex.c,v 1.8 2012/02/20 04:43:49 guenther Exp $ */ /* * Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors, * proven@mit.edu All rights reserved. @@ -45,6 +45,7 @@ #include <pthread_np.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include "test.h" int contention_variable; @@ -75,7 +76,7 @@ test_contention_lock(pthread_mutex_t *mutex) pthread_yield(); contention_variable = 1; CHECKr(pthread_mutex_unlock(mutex)); - pthread_yield(); + sleep(1); CHECKr(pthread_mutex_lock(mutex)); ASSERT(contention_variable == 2); CHECKr(pthread_mutex_unlock(mutex)); |