Hello,
I work on an ARM9 with the API Posix and I found a problem during my tests.
I have written a simple example who show this problem.
Here is my code :
#include <pthread.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <limits.h>
#include <mqueue.h>
void routine (void * cookie);
void routine (void * cookie)
{
struct timespec timeout;
struct sched_param param = {.sched_priority = 10 };
pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);
timeout.tv_sec=0;
timeout.tv_nsec=200000000;
nanosleep ( &timeout, NULL);
printf("destruction tache\n");
pthread_exit(NULL);
}
int main(int argc, char **argv)
{
int i = 0;
int err;
pthread_attr_t attr;
pthread_t task;
struct timespec timeout, timeout2;
struct sched_param param = {.sched_priority = 10 };
mlockall(MCL_CURRENT | MCL_FUTURE);
timeout.tv_sec=50;
timeout.tv_nsec=0;
timeout2.tv_sec=0;
timeout2.tv_nsec=500000000;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setschedparam(&attr, ¶m);
pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
for(i=0;i<10000;i++){
printf("Tour %d\n", i);
if (err = pthread_create (&task,&attr,(void *)routine,NULL))
fprintf(stderr, "failed to create threads: %s\n", strerror(err));
if (err = pthread_create (&task,&attr,(void *)routine,NULL))
fprintf(stderr, "failed to create threads: %s\n", strerror(err));
if (err = pthread_create (&task,&attr,(void *)routine,NULL))
fprintf(stderr, "failed to create threads: %s\n", strerror(err));
nanosleep ( &timeout2, NULL);
}
nanosleep ( &timeout, NULL);
return 0;
}
At the turn 509, it doesn't work any more. Ressources are unavailable to
create another task.
Thanks
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help