Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Dec 1998 18:09:34 -0500
From:      Larry Ching <lching@cisco.com>
To:        hackers@FreeBSD.ORG
Cc:        lching@cisco.com
Subject:   pthreads question
Message-ID:  <367AE0AE.4820BC12@cisco.com>

next in thread | raw e-mail | index | archive | help
Greetings.

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.

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.

What is the expected behaviour here?  Is there a better way to do
this?

Thanks for any and all help.

Larry Ching
Cisco Systems


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?367AE0AE.4820BC12>