All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Perrine Martignoni <perrmart@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Problem API Posix : ressource temporarily unavailable
Date: Wed, 23 May 2007 15:59:03 +0200	[thread overview]
Message-ID: <465448A7.5080803@domain.hid> (raw)
In-Reply-To: <7289437c0705230649u5a09e726q86204106bb22a7b8@domain.hid>

Perrine Martignoni wrote:
> 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, &param);
> 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, &param);
> 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.

If you create a joinable thread, ressources remain allocated until the
thread is joined. If you do not intend to join your threads, then create
them detached.

-- 
                                                 Gilles Chanteperdrix


      reply	other threads:[~2007-05-23 13:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23 13:49 [Xenomai-help] Problem API Posix : ressource temporarily unavailable Perrine Martignoni
2007-05-23 13:59 ` Gilles Chanteperdrix [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=465448A7.5080803@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=perrmart@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.