summaryrefslogtreecommitdiff
path: root/lib/libpthread/pthread_mutex.c
diff options
context:
space:
mode:
authormatt <matt@NetBSD.org>2012-08-16 04:49:47 +0000
committermatt <matt@NetBSD.org>2012-08-16 04:49:47 +0000
commit6a3069e1c50fa610f804db3be271aa4ae210b024 (patch)
tree4fa288126e23a6b3717c3badfef8f9e5d11c61c4 /lib/libpthread/pthread_mutex.c
parentf54a3f5e69cc66993e101f08febc3fd40e22324d (diff)
Add a pthread__smt_wake and add support for it on arm along with
pthread__smt_pause. These are implemented using the ARM instructions SEV (wake) and WFE (pause). These are treated as NOPs on ARM CPUs that don't support them.
Diffstat (limited to 'lib/libpthread/pthread_mutex.c')
-rw-r--r--lib/libpthread/pthread_mutex.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libpthread/pthread_mutex.c b/lib/libpthread/pthread_mutex.c
index 110e98fa496..6b2c8d83873 100644
--- a/lib/libpthread/pthread_mutex.c
+++ b/lib/libpthread/pthread_mutex.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_mutex.c,v 1.53 2012/03/13 01:05:55 joerg Exp $ */
+/* $NetBSD: pthread_mutex.c,v 1.54 2012/08/16 04:49:47 matt Exp $ */
/*-
* Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.53 2012/03/13 01:05:55 joerg Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.54 2012/08/16 04:49:47 matt Exp $");
#include <sys/types.h>
#include <sys/lwpctl.h>
@@ -379,8 +379,10 @@ pthread_mutex_unlock(pthread_mutex_t *ptm)
#endif
self = pthread__self();
value = atomic_cas_ptr_ni(&ptm->ptm_owner, self, NULL);
- if (__predict_true(value == self))
+ if (__predict_true(value == self)) {
+ pthread__smt_wake();
return 0;
+ }
return pthread__mutex_unlock_slow(ptm);
}
@@ -475,6 +477,7 @@ pthread__mutex_wakeup(pthread_t self, pthread_mutex_t *ptm)
* are dependent upon 'thread'.
*/
thread = atomic_swap_ptr(&ptm->ptm_waiters, NULL);
+ pthread__smt_wake();
for (;;) {
/*