Date: Fri, 18 Dec 1998 23:17:25 -0500 (EST) From: Daniel Eischen <eischen@vigrid.com> To: hackers@FreeBSD.ORG, lching@cisco.com Subject: Re: pthreads question Message-ID: <199812190417.XAA10236@pcnet1.pcnet.com>
next in thread | raw e-mail | index | archive | help
> 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. > What is the expected behaviour here? Is there a better way to do > this? > > Thanks for any and all help. > > Larry Ching > Cisco Systems 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?199812190417.XAA10236>