From owner-freebsd-hackers Mon Dec 21 11:01:30 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA05477 for freebsd-hackers-outgoing; Mon, 21 Dec 1998 11:01:30 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from tornado.cisco.com (tornado.cisco.com [171.69.104.22]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA05462 for ; Mon, 21 Dec 1998 11:01:28 -0800 (PST) (envelope-from lching@cisco.com) Received: from lching-pc.cisco.com (lching-pc.cisco.com [171.69.206.55]) by tornado.cisco.com (8.8.5-Cisco.1/8.6.5) with ESMTP id OAA29477; Mon, 21 Dec 1998 14:01:18 -0500 (EST) Received: from cisco.com (localhost.cisco.com [127.0.0.1]) by lching-pc.cisco.com (8.8.8/8.8.8) with ESMTP id OAA08482; Mon, 21 Dec 1998 14:02:03 -0500 (EST) (envelope-from lching@cisco.com) Message-ID: <367E9B2B.9E5355DE@cisco.com> Date: Mon, 21 Dec 1998 14:02:03 -0500 From: Larry Ching X-Mailer: Mozilla 4.04 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) MIME-Version: 1.0 To: Daniel Eischen CC: hackers@FreeBSD.ORG, lching@cisco.com Subject: Re: pthreads question References: <199812190417.XAA10236@pcnet1.pcnet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Daniel Eischen wrote: > > I am having a problem porting an application that runs on FreeBSD > > 2.2.6 and doesn't on FreeBSD 3.0. The problem seems to be caused > > by differences in the pthreads implemention on the two systems. > > > > Trying to state the problem in its simplest terms, the application > > spawns a thread that continually tries to read data from a device. > > The thread, of course, blocks on the read() call if no data is > > available from the device. To terminate the read thread, another > > thread issues a pthread_kill() call to the read thread, which in > > 2.2.6 would cause the read() to return -1 with an errno of EINTR. > > This would cause the thread to terminate itself. However, under > > 3.0 the read does not return and the reader thread remains blocked. > > Each thread has it's own signal mask. Does the thread that you're > trying to interrupt have the signal blocked? > > > I have scanned through the pthread code under 3.0 and the difference > > seems to lie in the pthread_kill() code in uthread_kill.c. > > Specifically, the signal specified in pthread_kill() is just added > > to the signal list if the thread is in any other state except > > PS_SIGSUSPEND or PS_SIGWAIT. I believe that the reader thread is > > in PS_FDR_WAIT state at this point and thus nothing happens. > > A quick glance of the code shows that this is what happens only > if the signal is blocked in the thread. If the signal is unblocked, > then the thread should return with EINTR. Use sigprocmask(2) to > unblock the signal in the thread that you want to interrupt. Thank you for your help above. The thread in question was making acall to pthread_sigmask(SIG_UNBLOCK,...) to unblock the signal I was using in pthread_kill(). I changed this call to sigprocmask(SIG_UNBLOCK, ...) with no effect. The thread remains blocked in the read() call and no EINTR error code is returned. Any suggestions as to where to look next??? Larry Ching > > > Dan Eischen > eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message