From b1956fe5420530b5f79ae749a4a0dc7637d37ca1 Mon Sep 17 00:00:00 2001 From: otto <> Date: Thu, 1 Sep 2016 10:41:02 +0000 Subject: Less lock contention by using more pools for mult-threaded programs. tested by many (thanks!) ok tedu, guenther@ --- src/lib/libc/include/thread_private.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/lib/libc/include') diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h index c2e0cf0b3f..81caaaae68 100644 --- a/src/lib/libc/include/thread_private.h +++ b/src/lib/libc/include/thread_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: thread_private.h,v 1.27 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: thread_private.h,v 1.28 2016/09/01 10:41:02 otto Exp $ */ /* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman */ @@ -7,6 +7,9 @@ #include /* for FILE and __isthreaded */ +#define _MALLOC_MUTEXES 4 +void _malloc_init(int); + /* * The callbacks needed by libc to handle the threaded case. * NOTE: Bump the version when you change the struct contents! @@ -72,8 +75,8 @@ struct thread_callbacks { void (*tc_flockfile)(FILE *); int (*tc_ftrylockfile)(FILE *); void (*tc_funlockfile)(FILE *); - void (*tc_malloc_lock)(void); - void (*tc_malloc_unlock)(void); + void (*tc_malloc_lock)(int); + void (*tc_malloc_unlock)(int); void (*tc_atexit_lock)(void); void (*tc_atexit_unlock)(void); void (*tc_atfork_lock)(void); @@ -137,8 +140,8 @@ extern void *__THREAD_NAME(serv_mutex); #define _MUTEX_LOCK(mutex) do {} while (0) #define _MUTEX_UNLOCK(mutex) do {} while (0) #define _MUTEX_DESTROY(mutex) do {} while (0) -#define _MALLOC_LOCK() do {} while (0) -#define _MALLOC_UNLOCK() do {} while (0) +#define _MALLOC_LOCK(n) do {} while (0) +#define _MALLOC_UNLOCK(n) do {} while (0) #define _ATEXIT_LOCK() do {} while (0) #define _ATEXIT_UNLOCK() do {} while (0) #define _ATFORK_LOCK() do {} while (0) @@ -184,15 +187,15 @@ extern void *__THREAD_NAME(serv_mutex); /* * malloc lock/unlock prototypes and definitions */ -#define _MALLOC_LOCK() \ +#define _MALLOC_LOCK(n) \ do { \ if (__isthreaded) \ - _thread_cb.tc_malloc_lock(); \ + _thread_cb.tc_malloc_lock(n); \ } while (0) -#define _MALLOC_UNLOCK() \ +#define _MALLOC_UNLOCK(n) \ do { \ if (__isthreaded) \ - _thread_cb.tc_malloc_unlock(); \ + _thread_cb.tc_malloc_unlock(n); \ } while (0) #define _ATEXIT_LOCK() \ -- cgit v1.2.3-55-g6feb