Running an old threads app on a current system

  • Follow


I have an app (that I wrote) that uses threads.  It was compiled with
"Linux threads" - such that when run on the original system, you ended
up with 3 processes showing up in "ps".

Now, I'm running the app on a new system, which is, I believe, running
"Posix threads", and have noticed that you no longer have multiple
processes running.  I find this surprising; I had assumed you had to
recompile it in order to make it run with Posix threads.  But, it seems
to "just work".  But what I find really strange is the output of
"pstree", which is like this:

    myapp(2551)---{myapp}(2563)

2551 is the pid of myapp (the only one).  There is no process 2563.
So, what's up with that?

0
Reply gazelle2 (1306) 3/31/2007 1:45:40 AM

I demand that Kenny McCormack may or may not have written...

[snip]
> Now, I'm running the app on a new system, which is, I believe, running
> "Posix threads", and have noticed that you no longer have multiple
> processes running.  I find this surprising; I had assumed you had to
> recompile it in order to make it run with Posix threads.  But, it seems to
> "just work".

Presumably it's already linked against libpthread.

> But what I find really strange is the output of "pstree", which is like
> this:

>     myapp(2551)---{myapp}(2563)

> 2551 is the pid of myapp (the only one).  There is no process 2563.
> So, what's up with that?

Isn't there?
  $ ls /proc/2551/task
  $ ps -o pid,tid,tname,stat,time,cmd m 2551

-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
|   Let's keep the pound sterling

"Cybermen plus Daleks. Together we could upgrade the universe."
0
Reply news64 (1253) 3/31/2007 2:06:35 AM


In article <4ED1677D3C%news@youmustbejoking.demon.cu.invalid>,
Darren Salt  <news@youmustbejoking.demon.cu.invalid> wrote:
>I demand that Kenny McCormack may or may not have written...
>
>[snip]
>> Now, I'm running the app on a new system, which is, I believe, running
>> "Posix threads", and have noticed that you no longer have multiple
>> processes running.  I find this surprising; I had assumed you had to
>> recompile it in order to make it run with Posix threads.  But, it seems to
>> "just work".
>
>Presumably it's already linked against libpthread.

I guess you are saying that the new "Posix threads" version of
"libpthread" is designed to be drop in compatible with the old "Linux
threads" version of "libpthread", so it does "just work".  I guess I
always assumed (without much basis it seems) that they would not be
"drop in" compatible with each other.

>> But what I find really strange is the output of "pstree", which is like
>> this:
>
>>     myapp(2551)---{myapp}(2563)
>
>> 2551 is the pid of myapp (the only one).  There is no process 2563.
>> So, what's up with that?
>
>Isn't there?
>  $ ls /proc/2551/task
>  $ ps -o pid,tid,tname,stat,time,cmd m 2551

Indeed.  There it is.  Thanks.

Now, can you explain why they do it that way?  Am I getting the sense
that the new threads model isn't that much different from the old one?
I.e., that there's still a separate pid involved; it's just hidden a
little better.

0
Reply gazelle2 (1306) 3/31/2007 11:20:04 AM

I demand that Kenny McCormack may or may not have written...

> In article <4ED1677D3C%news@youmustbejoking.demon.cu.invalid>,
> Darren Salt  <news@youmustbejoking.demon.cu.invalid> wrote:
>> I demand that Kenny McCormack may or may not have written...
>> [snip]
>>> Now, I'm running the app on a new system, which is, I believe, running
>>> "Posix threads", and have noticed that you no longer have multiple
>>> processes running.
[snip]
>> Presumably it's already linked against libpthread.

> I guess you are saying that the new "Posix threads" version of "libpthread"
> is designed to be drop in compatible with the old "Linux threads" version
> of "libpthread", so it does "just work".

Hmm, yes, I suppose that I am...

[snip]
>>> But what I find really strange is the output of "pstree", which is like
>>> this:
>>>     myapp(2551)---{myapp}(2563)
>>> 2551 is the pid of myapp (the only one).  There is no process 2563.
>>> So, what's up with that?

>> Isn't there?
>>  $ ls /proc/2551/task
>>  $ ps -o pid,tid,tname,stat,time,cmd m 2551

> Indeed.  There it is.  Thanks.

> Now, can you explain why they do it that way?  Am I getting the sense that
> the new threads model isn't that much different from the old one? I.e.,
> that there's still a separate pid involved; it's just hidden a little
> better.

A quick search for "pthreads linux kernel" provided at least the following:

http://lwn.net/Articles/7001/
http://www.onlamp.com/pub/a/onlamp/2002/11/07/linux_threads.html

-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Output *more* particulate pollutants.      BUFFER AGAINST GLOBAL WARMING.

"Daleks will be deleted. DELETE! DELETE!"
0
Reply news64 (1253) 4/1/2007 1:45:06 AM

In article <4ED1E95BB8%news@youmustbejoking.demon.cu.invalid>,
Darren Salt  <news@youmustbejoking.demon.cu.invalid> wrote:
....
>> Now, can you explain why they do it that way?  Am I getting the sense that
>> the new threads model isn't that much different from the old one? I.e.,
>> that there's still a separate pid involved; it's just hidden a little
>> better.
>
>A quick search for "pthreads linux kernel" provided at least the following:
>
>http://lwn.net/Articles/7001/
>http://www.onlamp.com/pub/a/onlamp/2002/11/07/linux_threads.html

Interesting reading.  But you haven't directly answered my question.
Could you please do so?

(It sounds like the answer is "Yes, each 'kernel thread' gets a pid
assigned to it, but the pids are now better hidden from ps (*)".)

(*) I.e., all the threads of a process are underneath /proc/<mainpid>
instead of being siblings of /proc/<mainpid>.  And there is no "manager
thread" anymore.

0
Reply gazelle2 (1306) 4/1/2007 4:52:50 AM

4 Replies
34 Views

(page loaded in 0.078 seconds)


Reply: