[102] in Pthreads mailing list archive
Re: help for starting pthreads on later BSD
daemon@ATHENA.MIT.EDU (Christopher Provenzano)
Mon Aug 28 02:06:00 1995
To: "Jin Guojun[ITG]" <jin@george.lbl.gov>
Cc: pthreads@MIT.EDU
In-Reply-To: Your message of "Wed, 09 Aug 1995 11:50:27 PDT."
<199508091850.LAA15113@george.lbl.gov>
Date: Mon, 28 Aug 1995 01:49:11 EDT
From: Christopher Provenzano <proven@MIT.EDU>
> I have made pthreads working under FreeBSD 2.0.5, but there is a couple of
> issues:
> (1) obj/ directory must be created manually before doing make;
> otherwise, the above problem happens. I guess the following line
> does not work properly in Makefile
>
> .OBJDIR != if test -d ${.CURDIR}/obj ; then true ; else mkdir ${.CURDIR}/obj
> ||
> exit 1 ; fi ; echo ${.CURDIR}/obj
Yes, it doesn't work, because make does a chdir if the obj directory
exists BEFORE it starts reading the makefile. To fis the problem, I've
changed configure to create the obj directory at create time for beta4.
>
> (2) I do not know why input pipe causes threaded program deadlock:
>
> threaded.xviewer filename # works fine
> threaded.xviewer < filename # works fine
> cat filename | threaded.xviewer # deadlock on threaded.xviewer
> Ctrl-C or Ctrl-Z will kill or stop "cat", but leave "threaded.xviewer"
> hanging forever. kill -9 pid can terminate the threaded.xviewer.
> Any idea?
I don't know why one would work and not another. I wrote a small test program
and it worked fine so I need some more details. I do know that if there are
no threads running but there are threads waiting on I/O then signals delivered
to the process may not get handled. This is because the signal must be
delivered to a thread that doesn't have it masked (masks are per thread).
Currently the thread doesn't execute the signal handler until it is next
scheduled to run (because if a higher priority thread has it masked then
you don't want the signal handler to preempt the higher priority thread.)
But if the thread is waiting on I/O then it doesn't get run. I working on
a fix for this.
BTW POSIX signals with threads are just gross. If you need them I suggest
looking at the sigwait() routine which is in beta3.
CAP