|
From: David F. <fa...@kd...> - 2003-11-06 19:09:00
|
Hi, I'm running a multithreaded program through valgrind. In some earlier versions of valgrind (1.9.5 maybe?), threads used to get their own ID, as seen in pthread_self(), starting at 1 (IIRC 0 was the main thread). With valgrind_2_0_really or valgrind CVS HEAD (KDE CVS), the thread gets an ID of 0, like the main thread, which makes the debugging a little more difficult. Thanks, David. PS: please CC me any replies, I'm not subscribed. -- David FAURE, fa...@kd..., sponsored by Trolltech to work on KDE, Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org). |
|
From: Jeremy F. <je...@go...> - 2003-11-06 21:47:19
|
On Thu, 2003-11-06 at 11:08, David Faure wrote:
> I'm running a multithreaded program through valgrind.
>
> In some earlier versions of valgrind (1.9.5 maybe?), threads used to get their
> own ID, as seen in pthread_self(), starting at 1 (IIRC 0 was the main thread).
>
> With valgrind_2_0_really or valgrind CVS HEAD (KDE CVS), the thread
> gets an ID of 0, like the main thread, which makes the debugging a little more difficult.
I don't see this. I get the same results with current CVS and the
2.0_REALLY branch, which are both expected:
$ valgrind -q ./tt
tid=1
tid=2
tid=3
tid=4
tid=5
tid=6
tid=7
$ cat tt.c
#include <stdio.h>
#include <pthread.h>
static void *th(void *a)
{
printf("tid=%d\n", pthread_self());
}
int main()
{
pthread_t t[10];
pthread_t *pt = t;
th(NULL);
pthread_create(pt++, NULL, th, NULL);
pthread_create(pt++, NULL, th, NULL);
pthread_create(pt++, NULL, th, NULL);
pthread_create(pt++, NULL, th, NULL);
pthread_create(pt++, NULL, th, NULL);
pthread_create(pt++, NULL, th, NULL);
while(pt > t)
pthread_join(*--pt, NULL);
return 0;
}
BTW, running this natively gets tid's which are far from small integers:
$ ./tt
tid=1073894560
tid=1082293552
tid=1090686256
tid=1099078960
tid=1116949808
tid=1125342512
tid=1133735216
So long as the thread IDs are all distinct, you can't really rely on any
particular values...
J
|