Carole Casten
unread,Dec 3, 2022, 1:57:27 PM12/3/22You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Below is a program to test leaks in Pthreads. The program creates threads and joins them. The program has a pthread_create error when i=397000.
#include <stdio.h> // printf
#include <string.h> // strcpy
#include "pthread.h"
int main(int argc, char **argv)
{
pthread_attr_t sched_attr;
pthread_t thread[8];
unsigned i,j;
int err;
void* inc_thread_nr(void* arg);
pthread_attr_init(&sched_attr);
for (i = 0; i < 10000000; i++)
{
for(j=0; j<7; j++)
{
err = pthread_create(&thread[j], &sched_attr, (void*)inc_thread_nr, NULL);
if (err != 0)
{
printf("\nError in create err=%d",err);
goto finish;
}
}
for(j=0; j<7; j++)
{
err = pthread_join(thread[j],NULL);
if (err != 0)
{
printf("\nError in join err=%d",err);
goto finish;
}
}
if(i%1000==0)
printf("\ri=%d",i);
}
finish:
exit(0);
}
void* inc_thread_nr(void* arg)
{
return(NULL);
}