Gentoo Archives: gentoo-user

From: Mark Knecht <markknecht@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Is my system (really) using nptl
Date: Sat, 13 Oct 2012 18:42:01
Message-Id: CAK2H+efJ-XJ9+QeYy1fBN-EUo3gZkH_0QH1mdRY6cAmmrhEOwA@mail.gmail.com
In Reply to: Re: [gentoo-user] Is my system (really) using nptl by "Canek Peláez Valdés"
1 On Sat, Oct 13, 2012 at 11:16 AM, Canek Peláez Valdés <caneko@×××××.com> wrote:
2 > On Sat, Oct 13, 2012 at 12:10 PM, Mark Knecht <markknecht@×××××.com> wrote:
3 >> On Sat, Oct 13, 2012 at 9:15 AM, Canek Peláez Valdés <caneko@×××××.com> wrote:
4 >> <SNIP>
5 >>>
6 >>> We can only know seeing the code. Timur, this is the little test I
7 >>> made which creates 5 threads and runs them for 1 minute. In my case,
8 >>> `ps x` shows only 1 PID, care to give it a try?
9 >>>
10 >>> ----------------------
11 >>> #include <pthread.h> <<======
12 >>> #include <unistd.h>
13 >>> #include <stdlib.h>
14 >>> #include <stdio.h>
15 >>
16 >> Thanks for the test case. Like you I see only one thread. However the
17 >> test case wouldn't compile for me without the -pthread option so it
18 >> makes me wonder what happens to a program like I had pointed to
19 >> yesterday that uses the old style threading that did create lots of
20 >> process ids? Possibly an nptl system would still generate lots of ids
21 >> for that program and that's what he's seeing?
22 >>
23 >> Just curious. I don't program but I'm always sort of interested.
24 >
25 > You got your answer. NTPL stands for Native POSIX Thread *Library*. As
26 > it name says, it is a library (with support in the kernel and in
27 > glibc). If you don't use the library (-lpthread), you cannot make use
28 > of its advantages.
29 >
30 > What "old style threading" did you use for your test case?
31 >
32 > Regards.
33 > --
34 > Canek Peláez Valdés
35 > Posgrado en Ciencia e Ingeniería de la Computación
36 > Universidad Nacional Autónoma de México
37 >
38
39 As for 'old style' I only meant code that did threads but didn't use
40 the POSIX libraries. (I guess...)
41
42 Actually I hadn't run the test case at the time but was referring to
43 the one I pointed the OP at yesterday:
44
45 http://www.makelinux.net/alp/032
46
47 However it's essentially the same as yours (not as elegant, but
48 functionally similar). However the results shown on that page show
49 different pids for the threads. When I run that same code here I get
50 the same pids:
51
52 mark@c2stable ~ $ ./pthread2
53 main thread pid is 5387
54 child thread pid is 5387
55 ^C
56 mark@c2stable ~ $
57
58 Now, this does make me curious about some things running on my system.
59 Two for instance, Google Chrome and akonadi_agent, have LOTS of pids.
60 I was assuming those were different threads and were demonstrating
61 what the OP was asking about, but now I'm not so sure. How does a
62 single program on an nptl system generate all these different pids?
63
64 Thanks,
65 Mark

Replies

Subject Author
Re: [gentoo-user] Is my system (really) using nptl Matthew Finkel <matthew.finkel@×××××.com>
Re: [gentoo-user] Is my system (really) using nptl "Canek Peláez Valdés" <caneko@×××××.com>