Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, use
it as a default spin cycle count.
This commit is contained in:
parent
5a984630fa
commit
e034ab54f2
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user