Date: Mon, 21 Dec 1998 14:02:03 -0500 From: Larry Ching <lching@cisco.com> To: Daniel Eischen <eischen@vigrid.com> Cc: hackers@FreeBSD.ORG, lching@cisco.com Subject: Re: pthreads question Message-ID: <367E9B2B.9E5355DE@cisco.com> References: <199812190417.XAA10236@pcnet1.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?367E9B2B.9E5355DE>