Results 1 to 3 of 3
What is the quickest way to get the thread id(tid) of the current thread in linux?
Specifically I use fedora 13. ...and I am talking about inside a C++ program....
- 06-24-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 28
Quickest way to get thread id(tid?)?
What is the quickest way to get the thread id(tid) of the current thread in linux?
Specifically I use fedora 13. ...and I am talking about inside a C++ program.
- 06-25-2010 #2Linux Newbie
- Join Date
- Mar 2010
- Posts
- 121
There is a system call for this, but not a library call, so you have to use the syscall() interface to invoke the gettid() system call:
- #define _GNU_SOURCE
- #include unistd.h, sys/syscall.h and sys/types.h
- Call `syscall(SYS_gettid)', which returns a value of type pid_t
- 06-25-2010 #3Linux Newbie
- Join Date
- Apr 2007
- Posts
- 119
pthread_self() will return the thread id of the calling thread.


Reply With Quote