Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Add a pthread__smt_wake and add support for i...
details: https://anonhg.NetBSD.org/src/rev/599a836a4f6a
branches: trunk
changeset: 781038:599a836a4f6a
user: matt <matt%NetBSD.org@localhost>
date: Thu Aug 16 04:49:47 2012 +0000
description:
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:
lib/libpthread/arch/arm/pthread_md.h | 5 ++++-
lib/libpthread/pthread_int.h | 5 ++++-
lib/libpthread/pthread_mutex.c | 9 ++++++---
lib/libpthread/pthread_spin.c | 5 +++--
4 files changed, 17 insertions(+), 7 deletions(-)
diffs (102 lines):
diff -r 930db33c61a1 -r 599a836a4f6a lib/libpthread/arch/arm/pthread_md.h
--- a/lib/libpthread/arch/arm/pthread_md.h Thu Aug 16 00:40:28 2012 +0000
+++ b/lib/libpthread/arch/arm/pthread_md.h Thu Aug 16 04:49:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.6 2011/01/25 19:12:04 christos Exp $ */
+/* $NetBSD: pthread_md.h,v 1.7 2012/08/16 04:49:48 matt Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -49,6 +49,9 @@
return (ret);
}
+#define pthread__smt_pause() __asm __volatile("wfe")
+#define pthread__smt_wake() __asm __volatile("sev")
+
#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
/*
diff -r 930db33c61a1 -r 599a836a4f6a lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h Thu Aug 16 00:40:28 2012 +0000
+++ b/lib/libpthread/pthread_int.h Thu Aug 16 04:49:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_int.h,v 1.85 2012/05/04 12:26:33 joerg Exp $ */
+/* $NetBSD: pthread_int.h,v 1.86 2012/08/16 04:49:47 matt Exp $ */
/*-
* Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -299,6 +299,9 @@
#ifndef pthread__smt_pause
#define pthread__smt_pause() /* nothing */
#endif
+#ifndef pthread__smt_wake
+#define pthread__smt_wake() /* nothing */
+#endif
/*
* Bits in the owner field of the lock that indicate lock state. If the
diff -r 930db33c61a1 -r 599a836a4f6a lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c Thu Aug 16 00:40:28 2012 +0000
+++ b/lib/libpthread/pthread_mutex.c Thu Aug 16 04:49:47 2012 +0000
@@ -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 @@
#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 @@
* are dependent upon 'thread'.
*/
thread = atomic_swap_ptr(&ptm->ptm_waiters, NULL);
+ pthread__smt_wake();
for (;;) {
/*
diff -r 930db33c61a1 -r 599a836a4f6a lib/libpthread/pthread_spin.c
--- a/lib/libpthread/pthread_spin.c Thu Aug 16 00:40:28 2012 +0000
+++ b/lib/libpthread/pthread_spin.c Thu Aug 16 04:49:47 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_spin.c,v 1.5 2008/04/28 20:23:01 martin Exp $ */
+/* $NetBSD: pthread_spin.c,v 1.6 2012/08/16 04:49:47 matt Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_spin.c,v 1.5 2008/04/28 20:23:01 martin Exp $");
+__RCSID("$NetBSD: pthread_spin.c,v 1.6 2012/08/16 04:49:47 matt Exp $");
#include <sys/types.h>
#include <sys/ras.h>
@@ -133,6 +133,7 @@
self = pthread__self();
pthread__spinunlock(self, &lock->pts_spin);
+ pthread__smt_wake();
return 0;
}
Home |
Main Index |
Thread Index |
Old Index