SIGKILL when pthread_cond_wait
syed khader
sk.syed at yahoo.com
Mon Nov 6 06:33:15 PST 2006
Hi all
I am verifying pthread library on uClibc-0.9.29 on an ARM920T 2.6.11 linux kernel. When within an application if I call pthread_cond_wait() the application exits(actually it receives SIGKILL from somewhere) with following error message:
$strace app ( gives following error)
pthread_mutex_lock successful
Calling pthread_cond_wait
<unfinished ...>
+++ killed by SIGKILL +++
Is the SIGKILL coming from uClibc OR from pthread lib OR is it from kernel?
The same code works fine on a x86 box with gcc(3.4.6)
Regards
Syed
<<Code Snippet>>
void *inc_count(void *idp)
{
int j,i;
double result=0.0;
int *my_id = idp;
sleep(1);
for (i=0; i<TCOUNT; i++) {
pthread_mutex_lock(&count_mutex);
count++;
if((*my_id == 0) && (count == 5))
sleep(1);
if (count == COUNT_LIMIT) {
printf("calling pthread_cond_signal\n");
pthread_cond_signal(&count_threshold_cv);
printf("inc_count(): thread %d, count = %d Threshold reached.\n",
*my_id, count);
}
printf("inc_count(): thread %d, count = %d, unlocking mutex\n",
*my_id, count);
pthread_mutex_unlock(&count_mutex);
/* Do some work so threads can alternate on mutex lock */
for (j=0; j<1000; j++)
result = result + (double)random();
}
printf("Thread %d calling exit\n", *my_id);
pthread_exit(NULL);
}
void *watch_count(void *idp)
{
int *my_id = idp;
printf("Starting watch_count(): thread %d\n", *my_id);
pthread_mutex_lock(&count_mutex);
printf("pthread_mutex_lock successful\n");
while (count<COUNT_LIMIT) {
printf("Calling pthread_cond_wait \n");
pthread_cond_wait(&count_threshold_cv, &count_mutex);
printf("Returned from pthread_cond_wait \n");
printf("watch_count(): thread %d Condition signal received.\n", *my_id);
}
pthread_mutex_unlock(&count_mutex);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
int i, rc;
pthread_t threads[3];
pthread_attr_t attr;
pthread_mutex_init(&count_mutex, NULL);
pthread_cond_init (&count_threshold_cv, NULL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_create(&threads[0], &attr, inc_count, (void *)&thread_ids[0]);
pthread_create(&threads[1], &attr, inc_count, (void *)&thread_ids[1]);
pthread_create(&threads[2], &attr, watch_count, (void *)&thread_ids[2]);
for (i=0; i<NUM_THREADS; i++) {
pthread_join(threads[i], NULL);
}
printf ("Main(): Waited on %d threads. Done.\n", NUM_THREADS);
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&count_mutex);
pthread_cond_destroy(&count_threshold_cv);
printf("Parent thread exitting\n");
pthread_exit(NULL);
}
More information about the uClibc
mailing list