Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo User (http://www.linux-archive.org/gentoo-user/)
-   -   Is my system (really) using nptl (http://www.linux-archive.org/gentoo-user/711773-my-system-really-using-nptl.html)

Timur Aydin 10-12-2012 01:24 PM

Is my system (really) using nptl
 
Hi,

I have done many tests on my ~x86 system to confirm that it is nptl based:

- I have the nptl and nptlonly use flags in my make.conf and my system
is up to date.

- Running /lib/libc.so.6 shows:

ta@bonsai ~ $ /lib/libc.so.6
GNU C Library stable release version 2.15, by Roland McGrath et al.
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.5.3.
Compiled on a Linux 3.5.0 system on 2012-09-10.
Available extensions:
C stubs add-on version 2.1.2
crypt add-on version 2.1 by Michael Glad and others
Gentoo patchset 21
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
Support for some architectures added on, not maintained in glibc
core.
BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

- getconf also indicates nptl:

ta@bonsai ~ $ getconf GNU_LIBPTHREAD_VERSION
NPTL 2.15


Yet, when I look at the process list, I am seeing all programs that use
threads having uniquey pid's for each thread. I even compiled a simple
program that just creates 5 threads, each sleeping forever. Again, each
thread had a unique pid.

I have also checked the kernel config. FUTEX support was enabled, but
the top level selector (EXPERT options) was not selected. I guess the
top level selector just exposes the FUTEX selector and doesn't really
affect whether it is enabled or not.

So, what I am wondering now, is my system configured for NPTL or not?

--
Timur

Canek Peláez Valdés 10-12-2012 05:46 PM

Is my system (really) using nptl
 
On Fri, Oct 12, 2012 at 8:24 AM, Timur Aydin <ta@taydin.org> wrote:
> Hi,
>
> I have done many tests on my ~x86 system to confirm that it is nptl based:
>
> - I have the nptl and nptlonly use flags in my make.conf and my system
> is up to date.
>
> - Running /lib/libc.so.6 shows:
>
> ta@bonsai ~ $ /lib/libc.so.6
> GNU C Library stable release version 2.15, by Roland McGrath et al.
> Copyright (C) 2012 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
> Compiled by GNU CC version 4.5.3.
> Compiled on a Linux 3.5.0 system on 2012-09-10.
> Available extensions:
> C stubs add-on version 2.1.2
> crypt add-on version 2.1 by Michael Glad and others
> Gentoo patchset 21
> GNU Libidn by Simon Josefsson
> Native POSIX Threads Library by Ulrich Drepper et al
> Support for some architectures added on, not maintained in glibc
> core.
> BIND-8.2.3-T5B
> libc ABIs: UNIQUE IFUNC
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/libc/bugs.html>.
>
> - getconf also indicates nptl:
>
> ta@bonsai ~ $ getconf GNU_LIBPTHREAD_VERSION
> NPTL 2.15
>
>
> Yet, when I look at the process list, I am seeing all programs that use
> threads having uniquey pid's for each thread. I even compiled a simple
> program that just creates 5 threads, each sleeping forever. Again, each
> thread had a unique pid.
>
> I have also checked the kernel config. FUTEX support was enabled, but
> the top level selector (EXPERT options) was not selected. I guess the
> top level selector just exposes the FUTEX selector and doesn't really
> affect whether it is enabled or not.
>
> So, what I am wondering now, is my system configured for NPTL or not?

You arouse my curiosity. Maybe there is a bug in glibc in ~x86; I'm
running stable (but with vanilla sources 3.6.0), and I have basically
the same setup as you: my glibc states that it has NTPL, getconf also
says it so, and I have FUTEX support enabled. I just don't set ntpl
nor ntplonly in my use flags (I was under the impression they were
enabled by default). My little program with 5 threads gets listed as a
single PID in my "ps x" output.

sys-libs/glibc-2.15-r2, no use flags set (except for multilib, which
is mandatory)
sys-kernel/vanilla-sources-3.6.1

Regards.
--
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México

Volker Armin Hemmann 10-12-2012 11:55 PM

Is my system (really) using nptl
 
Am Freitag, 12. Oktober 2012, 16:24:59 schrieb Timur Aydin:
> Hi,
>
> I have done many tests on my ~x86 system to confirm that it is nptl based:
>
> - I have the nptl and nptlonly use flags in my make.conf and my system
> is up to date.
>
> - Running /lib/libc.so.6 shows:
>
> ta@bonsai ~ $ /lib/libc.so.6
> GNU C Library stable release version 2.15, by Roland McGrath et al.
> Copyright (C) 2012 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
> Compiled by GNU CC version 4.5.3.
> Compiled on a Linux 3.5.0 system on 2012-09-10.
> Available extensions:
> C stubs add-on version 2.1.2
> crypt add-on version 2.1 by Michael Glad and others
> Gentoo patchset 21
> GNU Libidn by Simon Josefsson
> Native POSIX Threads Library by Ulrich Drepper et al
> Support for some architectures added on, not maintained in glibc
> core.
> BIND-8.2.3-T5B
> libc ABIs: UNIQUE IFUNC
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/libc/bugs.html>.
>
> - getconf also indicates nptl:
>
> ta@bonsai ~ $ getconf GNU_LIBPTHREAD_VERSION
> NPTL 2.15
>
>
> Yet, when I look at the process list, I am seeing all programs that use
> threads having uniquey pid's for each thread. I even compiled a simple
> program that just creates 5 threads, each sleeping forever. Again, each
> thread had a unique pid.
>

and that is how it is done, isn't it?

> I have also checked the kernel config. FUTEX support was enabled, but
> the top level selector (EXPERT options) was not selected. I guess the
> top level selector just exposes the FUTEX selector and doesn't really
> affect whether it is enabled or not.

indeed.

>
> So, what I am wondering now, is my system configured for NPTL or not?

pretty sure: yes.

How about less YOURAPP:
Dynamic section at offset ... contains 27 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: ....
0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
?

--
#163933

Timur Aydin 10-13-2012 12:09 AM

Is my system (really) using nptl
 
>> So, what I am wondering now, is my system configured for NPTL or not?
>
> pretty sure: yes.
>
> How about less YOURAPP:
> Dynamic section at offset ... contains 27 entries:
> Tag Type Name/Value
> 0x0000000000000001 (NEEDED) Shared library: ....
> 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
> ?

That's what my app has.

0x00000001 (NEEDED) Shared library: [libpthread.so.0]

So isn't the process supposed to have one pid, regardless of how many
threads it has created?

--
Timur

Mark Knecht 10-13-2012 01:11 AM

Is my system (really) using nptl
 
Take look here. The answer is, I think, not necessarily.

http://www.makelinux.net/alp/032

HTH,
Mark

Timur Aydin 10-13-2012 11:15 AM

Is my system (really) using nptl
 
On 10/13/12 04:11, Mark Knecht wrote:
> Take look here. The answer is, I think, not necessarily.
>
> http://www.makelinux.net/alp/032
>

Hello Mark,

Thank you for the link to an excellent book. However, it seems the book
is talking about linuxthreads by Xavier Leroy, not nptl. I am well aware
that linuxthreads uses LWP's to implement threads and as a result, each
thread has a separate, unique pid.

I did a few more tests using gdb and my simple app. I am seeing the
SIG32 signal and the lack of the manager threads. So everything hints
that I am indeed using nptl, but the separate process id's still doesn't
make sense...

--
Timur

Volker Armin Hemmann 10-13-2012 12:09 PM

Is my system (really) using nptl
 
Am Samstag, 13. Oktober 2012, 14:15:50 schrieb Timur Aydin:
> On 10/13/12 04:11, Mark Knecht wrote:
> > Take look here. The answer is, I think, not necessarily.
> >
> > http://www.makelinux.net/alp/032
>
> Hello Mark,
>
> Thank you for the link to an excellent book. However, it seems the book
> is talking about linuxthreads by Xavier Leroy, not nptl. I am well aware
> that linuxthreads uses LWP's to implement threads and as a result, each
> thread has a separate, unique pid.
>
> I did a few more tests using gdb and my simple app. I am seeing the
> SIG32 signal and the lack of the manager threads. So everything hints
> that I am indeed using nptl, but the separate process id's still doesn't
> make sense...

or you made a mistake somewhere in your app.

--
#163933

Michael Mol 10-13-2012 12:51 PM

Is my system (really) using nptl
 
On Sat, Oct 13, 2012 at 7:15 AM, Timur Aydin <ta@taydin.org> wrote:
> On 10/13/12 04:11, Mark Knecht wrote:
>> Take look here. The answer is, I think, not necessarily.
>>
>> http://www.makelinux.net/alp/032
>>
>
> Hello Mark,
>
> Thank you for the link to an excellent book. However, it seems the book
> is talking about linuxthreads by Xavier Leroy, not nptl. I am well aware
> that linuxthreads uses LWP's to implement threads and as a result, each
> thread has a separate, unique pid.
>
> I did a few more tests using gdb and my simple app. I am seeing the
> SIG32 signal and the lack of the manager threads. So everything hints
> that I am indeed using nptl, but the separate process id's still doesn't
> make sense...

I'm a little late to the conversation...but is there an NPTL-directed
sample program somewhere you can use as a baseline? i.e., to be able
to say, "if this works, I know NPTL does, and I know what an NPTL
program looks like at the system level."

--
:wq

Canek Peláez Valdés 10-13-2012 04:15 PM

Is my system (really) using nptl
 
On Sat, Oct 13, 2012 at 7:09 AM, Volker Armin Hemmann
<volkerarmin@googlemail.com> wrote:
> Am Samstag, 13. Oktober 2012, 14:15:50 schrieb Timur Aydin:
>> On 10/13/12 04:11, Mark Knecht wrote:
>> > Take look here. The answer is, I think, not necessarily.
>> >
>> > http://www.makelinux.net/alp/032
>>
>> Hello Mark,
>>
>> Thank you for the link to an excellent book. However, it seems the book
>> is talking about linuxthreads by Xavier Leroy, not nptl. I am well aware
>> that linuxthreads uses LWP's to implement threads and as a result, each
>> thread has a separate, unique pid.
>>
>> I did a few more tests using gdb and my simple app. I am seeing the
>> SIG32 signal and the lack of the manager threads. So everything hints
>> that I am indeed using nptl, but the separate process id's still doesn't
>> make sense...
>
> or you made a mistake somewhere in your app.

We can only know seeing the code. Timur, this is the little test I
made which creates 5 threads and runs them for 1 minute. In my case,
`ps x` shows only 1 PID, care to give it a try?

----------------------
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static int keep_running;

static void*
my_thread(void* data)
{
int id = *((int*)data);
int count = 0;

sleep(id);
printf("Thread %d beginning.
", count++);

while (keep_running) {
printf("Thread %d: %d.
", id, count++);
sleep(1);
}
printf("Thread %d exiting.
", count++);
}

int
main(int argc, char* argv[])
{
keep_running = 1;
pthread_t a, b, c, d, e;
int* arr[] = { NULL, NULL, NULL, NULL, NULL };
int i;
for (i = 0; i < 5; i++) {
arr[i] = malloc(sizeof(int));
*arr[i] = i;
}
pthread_create(&a, NULL, my_thread, arr[0]);
pthread_create(&b, NULL, my_thread, arr[1]);
pthread_create(&c, NULL, my_thread, arr[2]);
pthread_create(&d, NULL, my_thread, arr[3]);
pthread_create(&e, NULL, my_thread, arr[4]);
sleep(60);
pthread_mutex_lock(&mutex);
keep_running = 0;
pthread_mutex_unlock(&mutex);
for (i = 0; i < 5; i++)
free(arr[i]);
}
----------------------

Regards.
--
Canek Peláez Valdés
Posgrado en Ciencia e Ingeniería de la Computación
Universidad Nacional Autónoma de México

Mark Knecht 10-13-2012 05:10 PM

Is my system (really) using nptl
 
On Sat, Oct 13, 2012 at 9:15 AM, Canek Peláez Valdés <caneko@gmail.com> wrote:
<SNIP>
>
> We can only know seeing the code. Timur, this is the little test I
> made which creates 5 threads and runs them for 1 minute. In my case,
> `ps x` shows only 1 PID, care to give it a try?
>
> ----------------------
> #include <pthread.h> <<======
> #include <unistd.h>
> #include <stdlib.h>
> #include <stdio.h>

Thanks for the test case. Like you I see only one thread. However the
test case wouldn't compile for me without the -pthread option so it
makes me wonder what happens to a program like I had pointed to
yesterday that uses the old style threading that did create lots of
process ids? Possibly an nptl system would still generate lots of ids
for that program and that's what he's seeing?

Just curious. I don't program but I'm always sort of interested.

Cheers,
Mark


All times are GMT. The time now is 08:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.