Date: Mon, 1 Mar 1999 15:10:46 -0600 From: "Richard Seaman, Jr." <dick@tar.com> To: John Plevyak <jplevyak@inktomi.com> Cc: Terry Lambert <tlambert@primenet.com>, hackers@FreeBSD.ORG Subject: Re: lockf and kernel threads Message-ID: <19990301151046.G1046@tar.com> In-Reply-To: <19990301091105.B21935@tsdev.inktomi.com>; from John Plevyak on Mon, Mar 01, 1999 at 09:11:05AM -0800 References: <19990224165840.A19033@proxydev.inktomi.com> <199902272043.NAA14007@usr09.primenet.com> <19990301091105.B21935@tsdev.inktomi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 01, 1999 at 09:11:05AM -0800, John Plevyak wrote: > On Sat, Feb 27, 1999 at 08:43:33PM +0000, Terry Lambert wrote: > > As a general comment on your original problem, the correct way to > > handle signals (according to the pthreads model) is to disable > > disnals in all threads but one, which is designated as the signal > > handling thread. This is recommended by many people, and in IMO is best. But, its not a requirement for POSIX pthreads, and POSIX compliant pthreads needs to deal with signals which are not handled this way. > > One problem here is that FreeBSD kernel threads using rfork get > > different PID's, so the signal handling will never work correctly > > anyway. Correct. Not only is signal handling not correct, neither is priority handling, not wait handling, nor any other syscalls that reference pids. POSIX pthreads says that threads should all have the same pid as the process that spawns them. The FreeBSD kernel needs some changes to handle POSIX compliant kernel pthreads. > > For user space threads and the Linux crap, the signal handling > > should be possible, if you follow the disallow-all-but-one-thread > > rule. > > I considered that also. There are a few problems with this: > > 1. some signals cannot be blocked. In particular, if the non-locking > thread is 'KILL'ed, then the lock will never be released in the > current code. > > 2. the abort(3) code explicitly unblocks the calling threads signal > handler so that strategy will not work for asserts, aborts. > > 3. signals are used for other purposes, some of which are not > amenable to the 'disallow-all-but-on-thread' technique. AKAIK, here's an abbreviated version of what POSIX says about signal handling: 1) Sigaction is shared by all threads. 2) Sigmasks are per thread. 3) Signal delivery depends. A synchronous signal generated by an exception is delivered to the thread that generated it. A signal sent to a thread by pthread_kill is delivered to the target thread. A signal sent to the process as a whole is delivered to one thread of the process that has not masked the signal (or if all threads have masked it, it is held pending until some thread unblocks it). The shared signal handling code added to the kernel in Dec/Jan (is this the "Linux crap" Terry refers to?) implement 1) and 2) above. Complete compliance with 3) requires more changes. -- Richard Seaman, Jr. email: dick@tar.com 5182 N. Maple Lane phone: 414-367-5450 Chenequa WI 53058 fax: 414-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990301151046.G1046>