Lionel Perrin wrote:
> Thanks for your answer. That's really great to have support so quickly. :)
> > > I got some difficulties to use either rt_alarm_wait or clock_nanosleep.
> > > It seems i haven't understood what's a "context that can sleep".
> > >
> > > First of all, what do we need to use clock_nanosleep ?
> > > Is it impossible to use this function in the main thread ?
> >
> > Xenomai clock_nanosleep, nanosleep or rt_alarm_wait services are
> > reserved to Xenomai real-time threads, and will return an error of EPERM
> > otherwise.
> >
> Ok. So the thread "main" is not a Xenomai real-time, right ?
>
> > If you want to obtain a Xenomai real-time thread using the posix skin
> > you have to make it use the SCHED_FIFO policy, either by creating it
> > with the pthread_create service, specifying non null creation attributes
> > or by changing the scheduling policy of an existing thread with
> > the pthread_setschedparam service.
> >
> Is it possible to apply those methods to the thread "main" ?
You can not create the main thread with pthread_create, but you can make
it real-time with pthread_setschedparam.
> There's still my sched_setscheduler enigma.
> Why the following program need the commented line to run perfectly, and
> why nanosleep failed without those lines ?
Maybe because the default value of the inheritsched attribute is not
what you expect ? You can check if a thread uses a real-time scheduling
policy with pthread_getschedparam.
> (...)
> if(pthread_attr_init(&th_attr))
> perror("pthead_attr_init");
>
> if (pthread_attr_setschedpolicy(&th_attr, SCHED_FIFO))
> perror("pthread_attr_setschedpolicy");
>
> if (pthread_create(&th, &th_attr, task, NULL))
> perror("pthread_create");;
>
> if(pthread_join(th, NULL))
> perror("pthread_join");
> (...)
perror will not work with pthread_* services: they do not use errno,
they return errors directly.
--
Gilles Chanteperdrix.
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help