summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread/uthread/uthread_mutex.c')
-rw-r--r--lib/libpthread/uthread/uthread_mutex.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c
index 1968c953a27..8cb8760046c 100644
--- a/lib/libpthread/uthread/uthread_mutex.c
+++ b/lib/libpthread/uthread/uthread_mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_mutex.c,v 1.7 1999/05/26 00:18:25 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.8 1999/06/09 07:06:54 d Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -223,6 +223,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
*/
else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
/*
+ * If the mutex was statically allocated, properly
+ * initialize the tail queue.
+ */
+ if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
+ TAILQ_INIT(&(*mutex)->m_queue);
+ (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
+ }
+
+ /*
* Guard against being preempted by a scheduling signal.
* To support priority inheritence mutexes, we need to
* maintain lists of mutex ownerships for each thread as
@@ -353,6 +362,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
/*
+ * If the mutex was statically allocated, properly
+ * initialize the tail queue.
+ */
+ if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
+ TAILQ_INIT(&(*mutex)->m_queue);
+ (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
+ }
+
+ /*
* Guard against being preempted by a scheduling signal.
* To support priority inheritence mutexes, we need to
* maintain lists of mutex ownerships for each thread as