Re: Thread_Id

Arjan van de Ven
2005-07-05T13:01:51Z

On Tue, 2005-07-05 at 17:45 +0530, RVK wrote:
> Can anyone suggest me how to get the threadId using 2.6.x kernels.
> pthread_self() does not work and returns some -ve integer.

NAME
pthread_self - get the calling thread ID

SYNOPSIS
#include <pthread.h>

pthread_t pthread_self(void);

DESCRIPTION
The pthread_self() function shall return the thread ID of the
calling thread.

pthread_self() works just fine for me. But... what makes you think a
"negative" value is a failure? What interpretation are you giving to
thread ID that negative woudl be wrong? A pthreads thread ID is just a
cookie you only can use to give back to the pthread library functions in
places where it's needed...