Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, use

it as a default spin cycle count.
This commit is contained in:
davidxu 2006-12-20 04:43:34 +00:00
parent 5a984630fa
commit e034ab54f2
5 changed files with 8 additions and 1 deletions

View File

@ -66,6 +66,7 @@ pthreadlist _thread_gc_list = TAILQ_HEAD_INITIALIZER(_thread_gc_list);
int _thread_active_threads = 1;
atfork_head _thr_atfork_list = TAILQ_HEAD_INITIALIZER(_thr_atfork_list);
struct umutex _thr_atfork_lock = DEFAULT_UMUTEX;
int _thr_adaptive_spin = 0;
struct pthread_prio _thr_priorities[3] = {
{RTP_PRIO_MIN, RTP_PRIO_MAX, 0}, /* FIFO */
@ -423,6 +424,7 @@ init_private(void)
{
size_t len;
int mib[2];
char *p;
_thr_umutex_init(&_mutex_static_lock);
_thr_umutex_init(&_cond_static_lock);
@ -454,6 +456,8 @@ init_private(void)
_pthread_attr_default.stacksize_attr = _thr_stack_default;
TAILQ_INIT(&_thr_atfork_list);
if ((p = getenv("LIBPTHREAD_ADAPTIVE_SPIN")) != NULL)
_thr_adaptive_spin = atoi(p);
}
init_once = 1;
}

View File

@ -136,6 +136,7 @@ mutex_init(pthread_mutex_t *mutex,
pmutex->m_lock.m_owner = UMUTEX_UNOWNED;
pmutex->m_lock.m_flags = 0;
}
pmutex->m_lock.m_spincount = _thr_adaptive_spin;
*mutex = pmutex;
return (0);
}

View File

@ -583,6 +583,7 @@ extern size_t _thr_guard_default __hidden;
extern size_t _thr_stack_default __hidden;
extern size_t _thr_stack_initial __hidden;
extern int _thr_page_size __hidden;
extern int _thr_adaptive_spin __hidden;
/* Garbage thread count. */
extern int _gc_count __hidden;

View File

@ -36,6 +36,7 @@ _thr_umutex_init(struct umutex *mtx)
static struct umutex default_mtx = DEFAULT_UMUTEX;
*mtx = default_mtx;
mtx->m_spincount = _thr_adaptive_spin;
}
int

View File

@ -32,7 +32,7 @@
#include <strings.h>
#include <sys/umtx.h>
#define DEFAULT_UMUTEX {0, 0, {0, 0}, {0, 0, 0, 0}}
#define DEFAULT_UMUTEX {0}
typedef long umtx_t;