develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [PATCH] Further eliminate POSIX-emulation under LinuxThreads

Thread Previous | Thread Next
Rafael Garcia-Suarez
February 11, 2012 13:55
Re: [PATCH] Further eliminate POSIX-emulation under LinuxThreads
Message ID:
On 11 February 2012 20:57, Ævar Arnfjörð Bjarmason <> wrote:
> [This is a patch I've just committed to
> avar/remove-linuxthreads-pid-caching) I'll be pushing it to blead
> unless there are any sound objections to it]
> Under POSIX threads the getpid() and getppid() functions return the
> same values across multiple threads, i.e. threads don't have their own
> PID's. This is not the case under the obsolete LinuxThreads where each
> thread has a different PID, so getpid() and getppid() will return
> different values across threads.
> Ever since the first perl 5.0 we've returned POSIX-consistent
> semantics for $$, until v5.14.0-251-g0e21945 when the getpid() cache
> was removed. In 5.8.1 Rafael added further explicit POSIX emulation in
> perl-5.8.0-133-g4d76a34 [1] by explicitly caching getppid(), so that
> multiple threads would always return the same value.
> I don't think all this effort to emulate POSIX sematics is worth it. I
> think $$ and getppid() are OS-level functions that should always
> return the same as their C equivalents. I shouldn't have to use a
> module like Linux::Pid to get the OS version of the return values.
> This is also a complete non-issue in practice these days, LinuxThreads
> was a Linux 2.4 thread implementation that nobody maintains
> anymore[2], all modern Linux distros use NPTL threads which don't
> suffer from this discrepancy.

+1 to the patch.
I remember having thought that THREADS_HAVE_PIDS was going to be
obsolete when I first heard about the NPTL thread model. ("Just keep
it in the core a couple of years, just in case"...)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About