From 5f00b957aee7c4cc6138734e4b4dc582cf4d10f9 Mon Sep 17 00:00:00 2001 From: davidxu Date: Wed, 1 Sep 2010 03:11:21 +0000 Subject: Change atfork lock from mutex to rwlock, also make mutexes used by malloc() module private type, when private type mutex is locked/unlocked, thread critical region is entered or leaved. These changes makes fork() async-signal safe which required by POSIX. Note that user's atfork handler still needs to be async-signal safe, but it is not problem of libthr, it is user's responsiblity. --- lib/libthr/thread/thr_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libthr/thread/thr_init.c') diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index ea567ee..e5dc2ce 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -65,7 +65,7 @@ pthreadlist _thread_list = TAILQ_HEAD_INITIALIZER(_thread_list); 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; +struct urwlock _thr_atfork_lock = DEFAULT_URWLOCK; struct pthread_prio _thr_priorities[3] = { {RTP_PRIO_MIN, RTP_PRIO_MAX, 0}, /* FIFO */ @@ -427,7 +427,7 @@ init_private(void) _thr_umutex_init(&_cond_static_lock); _thr_umutex_init(&_rwlock_static_lock); _thr_umutex_init(&_keytable_lock); - _thr_umutex_init(&_thr_atfork_lock); + _thr_urwlock_init(&_thr_atfork_lock); _thr_umutex_init(&_thr_event_lock); _thr_once_init(); _thr_spinlock_init(); -- cgit v1.1