diff options
author | Marco S Hyman <marc@cvs.openbsd.org> | 2001-11-12 02:24:31 +0000 |
---|---|---|
committer | Marco S Hyman <marc@cvs.openbsd.org> | 2001-11-12 02:24:31 +0000 |
commit | 11c30e289f54a168d95ce9734017853b21169f73 (patch) | |
tree | e8de6840f9a07d3643ac8b9c0d1e54f7a7c10575 /lib | |
parent | 66e5aa528eab6994ebf607531cdd9fb833e8aad0 (diff) |
This fixes the recursive mutex problem with pthreads.
fgs@ says their is a better fix... if so he can back these changes out
and apply his fix at his convenience. In the meanwhile we'll have
mutexen that work.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/uthread/uthread_mutex.c | 16 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_mutex.c | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c index 782808b5831..4fc3962fa83 100644 --- a/lib/libc_r/uthread/uthread_mutex.c +++ b/lib/libc_r/uthread/uthread_mutex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_mutex.c,v 1.11 2000/01/06 07:19:35 d Exp $ */ +/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -134,7 +134,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, /* Check mutex protocol: */ else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) || - ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE)) + ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT)) /* Return an invalid argument error: */ ret = EINVAL; @@ -438,6 +438,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) /* Lock the mutex for this thread: */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Add to the list of owned mutexes: */ _MUTEX_ASSERT_NOT_OWNED(*mutex); TAILQ_INSERT_TAIL(&_thread_run->mutexq, @@ -477,6 +481,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) /* Lock the mutex for this thread: */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Track number of priority mutexes owned: */ _thread_run->priority_mutex_count++; @@ -541,6 +549,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Track number of priority mutexes owned: */ _thread_run->priority_mutex_count++; diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c index 782808b5831..4fc3962fa83 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.11 2000/01/06 07:19:35 d Exp $ */ +/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */ /* * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -134,7 +134,7 @@ pthread_mutex_init(pthread_mutex_t * mutex, /* Check mutex protocol: */ else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) || - ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE)) + ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT)) /* Return an invalid argument error: */ ret = EINVAL; @@ -438,6 +438,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) /* Lock the mutex for this thread: */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Add to the list of owned mutexes: */ _MUTEX_ASSERT_NOT_OWNED(*mutex); TAILQ_INSERT_TAIL(&_thread_run->mutexq, @@ -477,6 +481,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) /* Lock the mutex for this thread: */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Track number of priority mutexes owned: */ _thread_run->priority_mutex_count++; @@ -541,6 +549,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex) */ (*mutex)->m_owner = _thread_run; + /* if recursive, increment the lock count */ + if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) + (*mutex)->m_data.m_count++; + /* Track number of priority mutexes owned: */ _thread_run->priority_mutex_count++; |