Date: Wed, 16 Apr 2003 20:03:22 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: Daniel Eischen <eischen@pcnet1.pcnet.com> Cc: freebsd-threads@freebsd.org Subject: Re: libpthread patch Message-ID: <3E9E197A.6CD504E2@mindspring.com> References: <Pine.GSO.4.10.10304161938070.18792-100000@pcnet1.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Daniel Eischen wrote: > On Thu, 17 Apr 2003, David Xu wrote: > > Hmm, I don't like to put malloc calling under critical section, > > it is better to put it under a lock, otherwise this would cause dead > > lock. suppose that an user thread is calling malloc(), and heap manager > > got malloc spinlock, then it does somethings and the thread is preempted > > by upcall from kernel, now UTS switches to another thread, that thread > > starts to call pthread_create, so UTS kernel enters a critical region first, > > and calls malloc, this would cause dead lock, because UTS is under critical > > region and no context switch could happen. > > Hmm, I see what you mean. We could put spinlock in critical region > and that may solve the problem, but I eventually want to see spinlocks > go away and replace the very few that we have in libc with mutexes. Critical sectioning AND locking are a bad idea. They are orthogonal technologies which are intended to solve the same basic problems. You guys need to decide whether you are locking code paths or if you are locking data objects. Pick one and only one, and stick with it consistently, or you will shoot your feet. So far, the FreeBSD 5.0 locking has been pretty schitzophrenic. -- Terry
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E9E197A.6CD504E2>