atom feed18 messages in org.freebsd.freebsd-threadspatch for threads/76690 - critical - ...
FromSent OnAttachments
Andriy TkachukMar 2, 2005 2:56 pm 
Daniel EischenMar 2, 2005 3:47 pm 
Andriy TkachukMar 3, 2005 6:35 am 
Daniel EischenMar 3, 2005 6:46 am 
David XuMar 3, 2005 6:48 am 
Andriy TkachukMar 3, 2005 6:58 am.patch
Andriy TkachukMar 3, 2005 7:29 am.cc
Andriy TkachukMar 3, 2005 8:07 am 
Andriy TkachukMar 3, 2005 8:10 am 
Andriy TkachukMar 3, 2005 8:15 am 
David XuMar 3, 2005 8:15 am 
Andriy TkachukMar 3, 2005 8:44 am 
Andriy TkachukMar 3, 2005 9:26 am.patch2
David XuMar 3, 2005 10:46 am 
Daniel EischenMar 3, 2005 3:14 pm 
Julian ElischerMar 3, 2005 8:29 pm 
David XuMar 4, 2005 3:24 am 
Andriy TkachukMar 4, 2005 5:57 am 
Subject:patch for threads/76690 - critical - fork hang in child for-lc_r
From:David Xu (davi@freebsd.org)
Date:Mar 3, 2005 10:46:40 am
List:org.freebsd.freebsd-threads

Andriy Tkachuk wrote:

Hmm, libc_r and libpthread handle spinlock differently which malloc uses to protect itself, some real world benchmarks are better than

this.

yes , you right, David. one have to check __isthreaded before firing _SPINLOCK. there will be nothing wrong, because

static spinlock_t thread_lock = _SPINLOCK_INITIALIZER;

initialyzed regardless __isthreaded in malloc.c but for optimization probably it is worth to add this check. Take a look on updated patch.

btw: i don't see the unlock in child in libpthread. there must be two unlocks - in child & in parent, doesn't it? :

# grep __malloc_lock -r libpthread libpthread/thread/thr_fork.c: _spinlock(__malloc_lock); libpthread/thread/thr_fork.c: if ((_kse_isthreaded() != 0) && (__malloc_lock != NULL)) { libpthread/thread/thr_fork.c: _spinunlock(__malloc_lock); #

in libpthread, all spinlocks hold by current thread are reinitialized by _thr_spinlock_init() in thr_spinlock.c, so in child process, it is not needed to unlocked it again. After a fork(), in child process, current thread is a fresh thread which should never hold any lock.