Subject: Re: linux signal delivery & clone() bug
To: Matthew Orgass <darkstar@pgh.net>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 11/07/2000 04:00:46
Matthew Orgass wrote:

> On Fri, 3 Nov 2000, Simon Burge wrote:
> > Jarom=EDr Dolecek <dolecek@ibis.cz>  wrote:
> > > The issue described in kern/10981 is fixed also with my version of patc=
> h
> > > (which has some comestic differences to the code in the PR).  I've also
> > > tried to make shared only the signal handler function array (I
> > > moved sa_mask and sa_flags to separate array), but that didn't help mtv
> 
>   sa_mask and sa_flags are per process, not per thread, since they are
> part of the signal handler.
> 
> > I tried a subset of this patch on my i386 (ie, only the MI and i386
> > parts), and I don't see what I would call proper behaviour.  When I try
> > the test program from the PR compiled natively against the pthreads
> > package, I see each "Thread N has pid X" line 1 second apart, and the
> > program exit cleanly.  With a Linux cross-compiled program (using the
> > suse_devel package) I see all "Thread ..." messages at the same time
> > but the program doesn't exit.  With a patched kernel, I still see all
> > the "Thread ..." messages at the same time but the program does exit
> > cleanly.
> >
> > >From reading the pthread_join() man page, the NetBSD native behaviour
> > is correct - each new thread should wait for the previous thread to
> > finish before it starts executing.
> 
>   The Linux behavior is correct, since all thread creates are done first
> then all thread joins are done, so all threads should sleep at the same
> time.  This is also the behvior when compiled with the PTL library on
> NetBSD.

From the manpage for pthread_join():

        > The pthread_join() function suspends execution of the calling
        > thread until the target thread terminates, unless the target
        > thread has already terminated.  On return from a successful
        > pthread_join() call with a non-NULL value_ptr argument, the
        > value passed to pthread_exit() by the terminating thread is
        > made available in the location referenced by value_ptr.  When
        > a pthread_join() returns successfully, the target thread has
        > been terminated. [ ... ]

I must be misinterpretting the manpage.  For the following loop

	for (Index=0; Index<NumThreads; Index++)
		(void)pthread_join(LWP[Index],NULL);

doesn't the last sentence quoted above imply that the next iteration
of the loop doesn't start until the thread designated by LWP[Index]
returns?

>   In the longer term, NetBSD needs to implement POSIX.1b signals.  If no
> one else is working on this I would be happy to take a shot at it [ ... ]

I don't beleive anyone is working on this at the moment, but I don't
know for sure...

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Sales, Support and Service:  http://www.wasabisystems.com/