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.
This commit is contained in:
parent
d4798304b1
commit
2f1e74f8c5
@ -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 @@ pthread__sp(void)
|
||||
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])
|
||||
|
||||
/*
|
||||
|
@ -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 @@ int pthread__checkpri(int) PTHREAD_HIDE;
|
||||
#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
|
||||
|
@ -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 (;;) {
|
||||
/*
|
||||
|
@ -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 @@ pthread_spin_unlock(pthread_spinlock_t *lock)
|
||||
|
||||
self = pthread__self();
|
||||
pthread__spinunlock(self, &lock->pts_spin);
|
||||
pthread__smt_wake();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user