Hi all,
I got this simple program creating 5 threads.
#include
#include
#include
void*
donothing(void* n)
{
int i;
for (;;i++)
sleep(i);
}
int
main()
{
pthread_t t[5];
int i = 0;
for (i = 0; i<5; i++)
pthread_create(&t[i], NULL, donothing, NULL);
donothing(NULL);
return 0;
}
Running this program, I see with ps xau, seven threads:
praise 10557 92.3 0.1 11912 376 pts/3 R 17:09 0:30 ./a.out
praise 10558 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
praise 10559 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
praise 10560 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
praise 10561 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
praise 10562 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
praise 10563 0.0 0.1 11912 376 pts/3 S 17:09 0:00 ./a.out
Why are they 7 and not 6? I create 5 threads, plus the main thread I thought I
had to get 6 threads. Why I see 7 threads istead?
Praise