summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>2000-01-06 07:18:47 +0000
committerDavid Leonard <d@cvs.openbsd.org>2000-01-06 07:18:47 +0000
commit8c84868319c9d38dd5f9b559f4897bbf0fe08a77 (patch)
tree7f6635dbd033a1de66ff83de66e8ffa157e27d51 /lib
parent119c84333926d9ff71fcc88a11331402226ccf63 (diff)
SPINLOCK_INIT, volatile
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_mutex.c12
-rw-r--r--lib/libpthread/uthread/uthread_mutex.c12
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c
index 1ddce4f6131..88ce0ee6200 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.9 1999/11/25 07:01:38 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.10 2000/01/06 07:18:46 d Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -188,10 +188,10 @@ pthread_mutex_init(pthread_mutex_t * mutex,
pmutex->m_prio = 0;
pmutex->m_saved_prio = 0;
_MUTEX_INIT_LINK(pmutex);
- memset(&pmutex->lock, 0, sizeof(pmutex->lock));
+ _SPINLOCK_INIT(&pmutex->lock);
*mutex = pmutex;
} else {
- free(pmutex);
+ free((void *)pmutex);
*mutex = NULL;
}
}
@@ -228,7 +228,7 @@ pthread_mutex_destroy(pthread_mutex_t * mutex)
* structure:
*/
_MUTEX_ASSERT_NOT_OWNED(*mutex);
- free(*mutex);
+ free((void *)*mutex);
/*
* Leave the caller's pointer NULL now that
@@ -304,6 +304,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
_MUTEX_ASSERT_NOT_OWNED(*mutex);
TAILQ_INSERT_TAIL(&_thread_run->mutexq,
(*mutex), m_qe);
+
} else if ((*mutex)->m_owner == _thread_run)
ret = mutex_self_trylock(*mutex);
else
@@ -1353,7 +1354,8 @@ mutex_queue_enq(pthread_mutex_t mutex, pthread_t pthread)
* at the tail of the queue.
*/
if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
+ TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
+ /* (pthread)->qe.tqe_prev = ((&mutex->m_queue))->tqh_last; */
else {
tid = TAILQ_FIRST(&mutex->m_queue);
while (pthread->active_priority <= tid->active_priority)
diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c
index 1ddce4f6131..88ce0ee6200 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.9 1999/11/25 07:01:38 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.10 2000/01/06 07:18:46 d Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -188,10 +188,10 @@ pthread_mutex_init(pthread_mutex_t * mutex,
pmutex->m_prio = 0;
pmutex->m_saved_prio = 0;
_MUTEX_INIT_LINK(pmutex);
- memset(&pmutex->lock, 0, sizeof(pmutex->lock));
+ _SPINLOCK_INIT(&pmutex->lock);
*mutex = pmutex;
} else {
- free(pmutex);
+ free((void *)pmutex);
*mutex = NULL;
}
}
@@ -228,7 +228,7 @@ pthread_mutex_destroy(pthread_mutex_t * mutex)
* structure:
*/
_MUTEX_ASSERT_NOT_OWNED(*mutex);
- free(*mutex);
+ free((void *)*mutex);
/*
* Leave the caller's pointer NULL now that
@@ -304,6 +304,7 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
_MUTEX_ASSERT_NOT_OWNED(*mutex);
TAILQ_INSERT_TAIL(&_thread_run->mutexq,
(*mutex), m_qe);
+
} else if ((*mutex)->m_owner == _thread_run)
ret = mutex_self_trylock(*mutex);
else
@@ -1353,7 +1354,8 @@ mutex_queue_enq(pthread_mutex_t mutex, pthread_t pthread)
* at the tail of the queue.
*/
if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
+ TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
+ /* (pthread)->qe.tqe_prev = ((&mutex->m_queue))->tqh_last; */
else {
tid = TAILQ_FIRST(&mutex->m_queue);
while (pthread->active_priority <= tid->active_priority)