[uClibc] pthreads BUG?
Miquel Sayeras Oliveras
u1016635 at correu.udg.es
Tue Dec 16 08:26:48 UTC 2003
The source code I've been testing:
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#define THREADS 1
pthread_t tid[THREADS];
void *prova(void *id)
{
int *tid;
tid = (int*)id;
sleep(7);
printf("Exit thread %d\n",*tid);
pthread_exit(0);
}
int main()
{
int contador;
printf("*******************************************************\n");
printf("* Testing class Thread with or without syncronization *\n");
printf("*******************************************************\n");
for(contador=0;contador<THREADS;contador++)
{
if( 0==pthread_create( &(tid[contador]),NULL,(void*)&prova,(void
*)&(tid[contador]) ) )
{
/*Comment if for waiting threads*/
if( 0==pthread_detach(tid[contador]) ) printf("Thread no esperat\n");
else printf("error\n");
}else perror("Thread no creat");
}
/*Uncomment for waiting threads*/
/*
printf("waiting threads\n");
for(contador = 0; contador<THREADS;contador++)
{
printf("Waiting for thread %d...\n",tid[contador]);
if( 0!=pthread_join( tid[contador], NULL ) ) perror("Error
join");
}
printf("Waited for all threads\n");
*/
while(1);
return 0;
}
> On Mon Dec 15, 2003 at 05:23:28PM -0800, Ken Treis wrote:
>> Miquel Sayeras Oliveras wrote:
>> >Somebody has been able to leave thread without this one remains zombie,
>> or
>> >creating thread like detached or doing pethread_exit and pthread_join.
>> >I've been trying for a while and I have not obtained that thread dies
>> >correctly. It's possible bug of threads scheduler??
>>
>> Just a "me too" on this (using on m68knommu). After a successful join,
>> the joined thread remains a zombie instead of being properly cleaned up.
>>
>> I ended up working around it by using a pthread_cond_wait instead of
>> creating/destroying threads.
>
> I don't run uClibc on m68knommu, but I have never seen the
> problem you describe on any other architectures. Can someone
> post a test app that demonstrates the problem?
>
> -Erik
>
> --
> Erik B. Andersen http://codepoet-consulting.com/
> --This message was written using 73% post-consumer electrons--
>
_______________________
Miquel Sayeras Oliveras
_______________________
More information about the uClibc
mailing list