summaryrefslogtreecommitdiffstats
path: root/src/ctl.c
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2017-06-09 05:46:31 (GMT)
committerQi Wang <interwq@gmail.com>2017-06-12 15:56:14 (GMT)
commit464cb60490efda800625b16fedd5bcd238e1526e (patch)
treecf9a1798be2a035bbe1e735c16cb056f0abc1666 /src/ctl.c
parent13685ab1b767091d817cb4959d24a42447a6fb78 (diff)
downloadjemalloc-464cb60490efda800625b16fedd5bcd238e1526e.zip
jemalloc-464cb60490efda800625b16fedd5bcd238e1526e.tar.gz
jemalloc-464cb60490efda800625b16fedd5bcd238e1526e.tar.bz2
Move background thread creation to background_thread_0.
To avoid complications, avoid invoking pthread_create "internally", instead rely on thread0 to launch new threads, and also terminating threads when asked.
Diffstat (limited to 'src/ctl.c')
-rw-r--r--src/ctl.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 134dbac..242b36d 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -1948,8 +1948,10 @@ arena_reset_prepare_background_thread(tsd_t *tsd, unsigned arena_ind) {
unsigned ind = arena_ind % ncpus;
background_thread_info_t *info =
&background_thread_info[ind];
- assert(info->started);
- background_threads_disable_single(tsd, info);
+ assert(info->started && !info->pause);
+ malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
+ info->pause = true;
+ malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
}
}
}
@@ -1961,8 +1963,10 @@ arena_reset_finish_background_thread(tsd_t *tsd, unsigned arena_ind) {
unsigned ind = arena_ind % ncpus;
background_thread_info_t *info =
&background_thread_info[ind];
- assert(!info->started);
- background_thread_create(tsd, ind);
+ assert(info->started && info->pause);
+ malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
+ info->pause = false;
+ malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
}
malloc_mutex_unlock(tsd_tsdn(tsd), &background_thread_lock);
}