shared variable

Nicolas Vignal nicolas.vignal@netline.fr
Wed Feb 7 06:26:00 GMT 2001


Hello

I know that shared variable must be lock. But behaviour of software under 
debugger and reality should be the same. If you try this little code under 
the last linux gdb snapshot you will see a difference.

On console I have :

I create the thread number 1026
I am the thread number 1026

Under gdb :

I am the thread number -1
I create the thread number 1026


Regards

	Nicolas


#include <stdio.h>
#include <pthread.h>

pthread_t threadID=-1;


int function(void)
{
  printf("I am the thread number %d\n",threadID);

  while (1);

  return 0;
}


int main(int argc, char *argv[])
{

  pthread_create(&threadID, NULL, function, NULL);
  printf("I create the thread number %d\n",threadID);

  return 0;
}


More information about the Gdb mailing list