Re: Periodic scheduling of 2 kernel tasks (different modules)

Shahbaz Youssefi <[email protected]> Mon, 8 May 2017 13:13:07 -0400
Newsgroups gmane.linux.real-time.rtai
Message-ID <CALeOzZ8mnOric4kgwLvpKT-EXw=Ds=z98=C3N--GP==LyxiBGQ@mail.gmail.com>
On Mon, May 8, 2017 at 11:51 AM, bhargavb <[email protected]> wrote:

> Hello,
>
> I am a beginner in rtai (and kernel module programming). Kindly answer
> below queries.
>
> *Question 1:*
> I have written 2 simple rtai kernel modules using periodic scheduling,
> both of them.
> One module prints one number each period (starting from 1 to 10
> incrementing each period) and other one does the same thing -1 to -10
> decrementing each period.
> There are no other rtai kernel modules that I have inserted except the two
> (apart from rtai hal,sched etc).
>
> In this scenario, where no other real time modules are inserted by me,
> shouldn't the behaviour be consistent? It is not happening so.
> If in a cycle it prints 1,-1,2,-2,3,-3,4,-4,5,-5,6,-6,
> 7,-7,8,-8,9,-9,10,-10
> in other cycle of execution (I do rmmod and insmod again), it prints some
> other pattern like 1,2,3,4,-1,-2,5,6, etc
>
> As long as same logic is present in each rtai kernel modules and no new
> rtai kernel module inserted or deleted, the output should be same each
> execution in real time. But it is not so. I did not get this. Please help
> me understand.
>

Please provide some code. What are the task priorities? Are you using
`printk` or `rt_printk`? How do you insert the modules (manually from the
terminal? A script that inserts one after the other)?


>
> *Question 2:*
> I have seen in some of the example code samples, *rt_set_oneshot_mode()*
> is called and then *start_rt_timer(1)*, then *rt_task_init()* and
> *rt_task_make_periodic()* . Does one shot mode setting of the timer have
> any effect in the sequence of calls? I understand the timer can be either
> set to one shot mode or periodic mode. I understand we are setting one shot
> mode initially and then overriding the setting by calling
> *rt_task_make_periodic()*. Is my understanding correct? I mean it is same
> as removing the call to rt_set_oneshot_mode()
>
> ---
> ---
> ---
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *  rt_set_oneshot_mode();
> timer_period_count=nano2count(timer_period_ns);
> start_rt_timer(timer_period_count);
> rt_task_init_cpuid(&tau_2,  /* pointer to our task structure
> */                 f_tau_2,       /* the task function */
> 0,             /* arg for f_tau_2 */                 1024,          /* size
> of the stack */                 100,           /* tau_2 has priority = 100
> */                 0,             /* we don't use floating point unit
> */                 0,             /* we don't use signals
> */                 0);            /* run on CPU 0 */
> rt_task_make_periodic(&tau_1, /* pointer to our task structure
> */                                  /* start 2 timer_periods from now
> */                          rt_get_time() +
> 2*timer_period_count,                          5*timer_period_count); /*
> recurring period (ignored in one-shot) */*
> ---
> ---
> ---
>
>
rt_set_oneshot_mode and start_rt_timer have to do with the scheduling clock
of RTAI as a whole, while rt_task_make_periodic identifies just one of the
tasks as periodic. From documentation of rt_task_make_periodic*:

Recall that the term clock ticks depends on the mode in which the hard
timer runs. So if the hard timer was set as periodic a clock tick will last
as the period set in start_rt_timer, while if oneshot mode is used a clock
tick will last as the inverse of the running frequency of the hard timer in
use and irrespective of any period used in the call to start_rt_timer.

If I recall correctly, oneshot mode is default (and periodic mode is
deprecated?)


>
> Thanks and regards,
> Bhargav
>
> _______________________________________________
> Rtai mailing list
> [email protected]
> https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
>

_______________________________________________
Rtai mailing list
[email protected]
https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai