diff options
author | Qi Wang <interwq@gwu.edu> | 2017-05-31 03:45:29 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-05-31 23:48:13 (GMT) |
commit | 508f54b02bd08ac0d250df1fa15cf87d574ce8a1 (patch) | |
tree | 6672c2ee24f14f5993abac43442f4eae020daf48 | |
parent | 9a86c9bd30e06daa20e4a4872d9292d177d66c8a (diff) | |
download | jemalloc-508f54b02bd08ac0d250df1fa15cf87d574ce8a1.zip jemalloc-508f54b02bd08ac0d250df1fa15cf87d574ce8a1.tar.gz jemalloc-508f54b02bd08ac0d250df1fa15cf87d574ce8a1.tar.bz2 |
Use real pthread_create for creating background threads.
-rw-r--r-- | src/background_thread.c | 10 | ||||
-rw-r--r-- | src/mutex.c | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/background_thread.c b/src/background_thread.c index d3e80b3..ccb50a2 100644 --- a/src/background_thread.c +++ b/src/background_thread.c @@ -364,7 +364,11 @@ background_thread_create(tsd_t *tsd, unsigned arena_ind) { pre_reentrancy(tsd); int err; load_pthread_create_fptr(); - if ((err = pthread_create(&info->thread, NULL, + /* + * To avoid complications (besides reentrancy), create internal + * background threads with the underlying pthread_create. + */ + if ((err = pthread_create_fptr(&info->thread, NULL, background_thread_entry, (void *)thread_ind)) != 0) { malloc_printf("<jemalloc>: arena %u background thread creation " "failed (%d).\n", arena_ind, err); @@ -645,7 +649,9 @@ load_pthread_create_fptr(void) { if (pthread_create_fptr) { return pthread_create_fptr; } - +#ifdef JEMALLOC_LAZY_LOCK + isthreaded = true; +#endif pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create"); if (pthread_create_fptr == NULL) { malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, " diff --git a/src/mutex.c b/src/mutex.c index 48e2940..2485222 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -30,7 +30,7 @@ static malloc_mutex_t *postponed_mutexes = NULL; static void pthread_create_once(void) { pthread_create_fptr = load_pthread_create_fptr(); - isthreaded = true; + assert(isthreaded); } JEMALLOC_EXPORT int |