Jack Whorn wrote:
> Hi,
>
> I`m new to Xenomai and I`m experiencing some issues.
>
> Why does a Xenomai thread (native skin) with an infinite loop hang the
> system, though there are higher-priority RT-threads present, and
> rt_task_set_mode periodically clears T_LOCK and T_SHIELD and sets T_RRB?
>
> Isn`t the scheduler preemptive, first considering the thread`s priority and
> subsequently the thread`s position in its priority`s ready queue?
>
> I have attached some sample code.
>
> Thanks for any hint,
>
> Jack
>
>
> #include <stdio.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <string.h>
> #include <sys/time.h>
> #include <sys/io.h>
> #include <sys/mman.h>
> #include <sys/types.h>
>
> #include <native/task.h>
> #include <native/queue.h>
> #include <native/intr.h>
> #include <native/timer.h>
>
>
> #define STACK_SIZE 8192
> #define PRIO 10
>
>
> static RT_TASK timer_task_desc;
>
> // ..s.ms.µs.ns
> static RTIME task_period_ns = 0100000000llu;
>
> static unsigned long overruns = 0;
>
> static void clean_exit(int dummy) {
>
> rt_task_delete(&timer_task_desc);
>
> }
>
> static void thread(void *cookie) {
>
> int ret;
> int i;
> int c;
>
>
> ret = rt_task_set_mode(T_LOCK, T_RRB, &c);
> if (ret)
> return;
>
> ret = rt_task_set_periodic(NULL, TM_NOW,
> rt_timer_ns2ticks(task_period_ns));
> if (ret)
> return;
>
> while (1) {
>
> ret = rt_task_set_mode(T_LOCK | T_SHIELD, T_RRB | T_PRIMARY, NULL);
> if (ret)
> return;
>
> ret = rt_task_wait_period(&overruns);
> if (ret == -ETIMEDOUT) {
> } else if (ret) {
> clean_exit(0);
> }
>
> while (1); /* infinite loop */
Once your program enters this infinte loop, it never gets out, so :
- your assumption that "t_task_set_mode periodically clears T_LOCK and
T_SHIELD and sets T_RRB" is false;
- even if higher priority task runs, Linux, which is Xenomai idle task
never runs, so the system locks up.
In short, maybe you have observed some scheduling problems, but your
example does not demonstrate them. Such misuse of Xenomai should be
caught by the watchdog, if you enable it.
--
Gilles Chanteperdrix.
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help