From: Srinivas Nayak on
Hi,

For a process, we have different PIDs. For threads under a single
processes, we have different LWP id, but same PID in Linux.
ex.

root(a)pc:/home/srinivas# ps -eLf
UID PID PPID LWP C STIME TIME CMD
root 100 1 100 0 May13 00:00:02 ./a.out
root 100 1 102 0 May13 00:00:00 ./a.out

getpid() function returns PID of a process.
Which function retuns LWP id for thread?

Sincerely,
Srinivas Nayak
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jaswinder Singh Rajput on
Hello,

On Mon, May 17, 2010 at 11:57 AM, Srinivas Nayak
<sinu.nayak2001(a)gmail.com> wrote:
> Hi,
>
> For a process, we have different PIDs. For threads under a single
> processes, we have different LWP id, but same PID in Linux.
> ex.
>
> root(a)pc:/home/srinivas# ps -eLf
> UID � � � �PID �PPID � � LWP �C STIME � � � TIME � � CMD
> root � � � 100 � � 1 � � 100 �0 May13 � � � 00:00:02 ./a.out
> root � � � 100 � � 1 � � 102 �0 May13 � � � 00:00:00 ./a.out
>
> getpid() function returns PID of a process.
> Which function retuns LWP id for thread?
>

You are asking procps question in LKML.

Please check http://procps.sourceforge.net/

Download propps package, read source code and you will get the reply.

Thanks,
--
Jaswinder Singh.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: KOSAKI Motohiro on
> Hi,
>
> For a process, we have different PIDs. For threads under a single
> processes, we have different LWP id, but same PID in Linux.
> ex.
>
> root(a)pc:/home/srinivas# ps -eLf
> UID PID PPID LWP C STIME TIME CMD
> root 100 1 100 0 May13 00:00:02 ./a.out
> root 100 1 102 0 May13 00:00:00 ./a.out
>
> getpid() function returns PID of a process.
> Which function retuns LWP id for thread?

gettid()



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jaswinder Singh Rajput on
Hello KOSAKI-san,

On Mon, May 17, 2010 at 12:33 PM, KOSAKI Motohiro
<kosaki.motohiro(a)jp.fujitsu.com> wrote:
>> Hi,
>>
>> For a process, we have different PIDs. For threads under a single
>> processes, we have different LWP id, but same PID in Linux.
>> ex.
>>
>> root(a)pc:/home/srinivas# ps -eLf
>> UID � � � �PID �PPID � � LWP �C STIME � � � TIME � � CMD
>> root � � � 100 � � 1 � � 100 �0 May13 � � � 00:00:02 ./a.out
>> root � � � 100 � � 1 � � 102 �0 May13 � � � 00:00:00 ./a.out
>>
>> getpid() function returns PID of a process.
>> Which function retuns LWP id for thread?
>
> gettid()
>

gettid() is linux specific and not supported in glibc. Normally
application do not use gettid(), even procps is not using it, that why
I suggested Srinivas to check procps source to find the best solution
for it.

Thanks,
--
Jaswinder Singh.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Srinivas Nayak on
>
> You are asking procps question in LKML.
>

Dear Jaswinder,

I am new to linux mailing lists. Thought, this process id related
question can only be answered by linux kernel developers, as they may be
working with this almost everyday. And more to this, I searched in the
Internet for LWP id, but found no positive answer. Many places gettid
was the answer, but it doesn't work.

I apologize, if lkml is not the best place to ask programming related
questions. It would be kind, if you let me know the correct mailing
list where general linux programming discussions happen. To my find,
linux-c-programming mailing list is not so active.

After some more research, i foind that

syscall(SYS_gettid)

returns LWP id. Isn't this correct?

Sincerely,
Srinivas Nayak
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/