* Which function returns LWP in Linux.
@ 2010-05-17 6:27 Srinivas Nayak
2010-05-17 6:56 ` Jaswinder Singh Rajput
2010-05-17 7:03 ` KOSAKI Motohiro
0 siblings, 2 replies; 7+ messages in thread
From: Srinivas Nayak @ 2010-05-17 6:27 UTC (permalink / raw)
To: linux-kernel
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@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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 6:27 Which function returns LWP in Linux Srinivas Nayak
@ 2010-05-17 6:56 ` Jaswinder Singh Rajput
2010-05-17 7:03 ` KOSAKI Motohiro
1 sibling, 0 replies; 7+ messages in thread
From: Jaswinder Singh Rajput @ 2010-05-17 6:56 UTC (permalink / raw)
To: Srinivas Nayak; +Cc: linux-kernel
Hello,
On Mon, May 17, 2010 at 11:57 AM, Srinivas Nayak
<sinu.nayak2001@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@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 6:27 Which function returns LWP in Linux Srinivas Nayak
2010-05-17 6:56 ` Jaswinder Singh Rajput
@ 2010-05-17 7:03 ` KOSAKI Motohiro
2010-05-17 7:33 ` Jaswinder Singh Rajput
1 sibling, 1 reply; 7+ messages in thread
From: KOSAKI Motohiro @ 2010-05-17 7:03 UTC (permalink / raw)
To: Srinivas Nayak; +Cc: kosaki.motohiro, linux-kernel
> 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@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()
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 7:03 ` KOSAKI Motohiro
@ 2010-05-17 7:33 ` Jaswinder Singh Rajput
2010-05-17 10:13 ` Srinivas Nayak
0 siblings, 1 reply; 7+ messages in thread
From: Jaswinder Singh Rajput @ 2010-05-17 7:33 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Srinivas Nayak, linux-kernel
Hello KOSAKI-san,
On Mon, May 17, 2010 at 12:33 PM, KOSAKI Motohiro
<kosaki.motohiro@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@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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 7:33 ` Jaswinder Singh Rajput
@ 2010-05-17 10:13 ` Srinivas Nayak
2010-05-17 13:30 ` Samuel Thibault
0 siblings, 1 reply; 7+ messages in thread
From: Srinivas Nayak @ 2010-05-17 10:13 UTC (permalink / raw)
To: Jaswinder Singh Rajput; +Cc: linux-kernel
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 10:13 ` Srinivas Nayak
@ 2010-05-17 13:30 ` Samuel Thibault
2010-05-17 18:13 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Samuel Thibault @ 2010-05-17 13:30 UTC (permalink / raw)
To: Srinivas Nayak; +Cc: Jaswinder Singh Rajput, linux-kernel
Srinivas Nayak, le Mon 17 May 2010 15:43:17 +0530, a écrit :
> After some more research, i foind that
>
> syscall(SYS_gettid)
>
> returns LWP id. Isn't this correct?
It is correct only on Linux, but yes.
Samuel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Which function returns LWP in Linux.
2010-05-17 13:30 ` Samuel Thibault
@ 2010-05-17 18:13 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2010-05-17 18:13 UTC (permalink / raw)
To: Samuel Thibault, Srinivas Nayak, Jaswinder Singh Rajput,
linux-kernel
On 05/17/2010 06:30 AM, Samuel Thibault wrote:
> Srinivas Nayak, le Mon 17 May 2010 15:43:17 +0530, a écrit :
>> After some more research, i foind that
>>
>> syscall(SYS_gettid)
>>
>> returns LWP id. Isn't this correct?
>
> It is correct only on Linux, but yes.
>
For libc's notion of the current thread, pthread_self(3).
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-05-17 18:14 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-17 6:27 Which function returns LWP in Linux Srinivas Nayak
2010-05-17 6:56 ` Jaswinder Singh Rajput
2010-05-17 7:03 ` KOSAKI Motohiro
2010-05-17 7:33 ` Jaswinder Singh Rajput
2010-05-17 10:13 ` Srinivas Nayak
2010-05-17 13:30 ` Samuel Thibault
2010-05-17 18:13 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).