[LITMUS^RT] running a task as its execution time

Giovani Gracioli giovanig at gmail.com
Wed Apr 25 22:05:24 CEST 2012


Hi Felipe,

Thank you for your answer. If I change the scheduler to PFAIR, for example,
the task is able to run correctly. If I change to PRECISE_ENFORCEMENT there
is a kernel panic at litmus/bugdet.c line 65 (using GSN-EDF scheduler),
because the elapsed time was greater the WCET.

I will try just to use PRECISE_ENFORCEMENT without setting the wcet in the
application.

Giovani

On Wed, Apr 25, 2012 at 4:58 PM, Felipe Cerqueira <
felipeqcerqueira at gmail.com> wrote:

> Hi Giovani,
>
> I've already faced something like that. The problem is that it's not safe
> to measure time within the application.
>
> Your loop_once() code only keeps iterating and acessing memory. In that
> case, I think there are only two factors causing the time difference. One
> of the sources of the difference is that the task may be preempted while
> you are measuring:
>
>         loop_start = read_tsc_us(); // reads from the TSC and converts to
> microsecond
>         tmp += loop_once();
>         -> Suppose the task is preempted right here
>         loop_end = read_tsc_us();
>
> Also, system interrupts may have ocurred between the measurements.
>
> In order to fix that, the application must communicate with the kernel.
> But even so, I don't know if it is possible to synchronize perfectly the
> loop in the code with the execution time of the task. The real-time job is
> independent of the code it runs.
>
> The task will run according to the execution time you provided at the
> initialization, but you can't check that via the application.
> The only thing you can change is the WCET enforcement:
>
> sporadic_task_ns(ctx->exec_time * 1000, ctx->period * 1000, 0, 0,
> RT_CLASS_HARD, QUANTUM_ENFORCEMENT, 0);
>
> Change to PRECISE_ENFORCEMENT if you want Litmus to use timers to enforce
> the execution. I'm not so sure, but I think if you keep
> QUANTUM_ENFORCEMENT, a completed job will only be removed until the next
> quantum.
>
> Best Regards,
> Felipe
>
> 2012/4/25 Giovani Gracioli <giovanig at gmail.com>
>
>> Hello,
>>
>> I am new at using LITMUS and I am facing some issues that maybe you can
>> help. I want to make sure that a task will execute only for its pre-defined
>> execution time, like this:
>>
>> //exec_time in microseconds
>> int loop_for(unsigned int exec_time)
>> {
>>     int tmp = 0;
>>     unsigned int elapsed = 0;
>>     unsigned long long loop_start = 0, loop_end = 0;
>>
>>     while(elapsed < exec_time) {
>>         loop_start = read_tsc_us(); // reads from the TSC and converts to
>> microsecond
>>         tmp += loop_once();
>>         loop_end = read_tsc_us();
>>         elapsed = elapsed + (loop_end - loop_start);
>>     }
>>
>>    printf("elapsed = %d, exec_time = %d\n", elapsed, exec_time);
>>
>>     return tmp;
>> }
>>
>> I choose the GSN-EDF scheduler by running "setsched" of liblitmus before
>> running the test application. The problem is that, the most of times, the
>> elapsed time is greater than the execution time. Here is a part of the
>> output:
>>
>> elapsed = 13003, exec_time = 921
>> elapsed = 12999, exec_time = 921
>> elapsed = 13003, exec_time = 921
>> elapsed = 13007, exec_time = 921
>> elapsed = 13007, exec_time = 921
>> elapsed = 12998, exec_time = 921
>> elapsed = 12995, exec_time = 921
>> elapsed = 12999, exec_time = 921
>> elapsed = 12990, exec_time = 921
>> elapsed = 921, exec_time = 921
>> elapsed = 13002, exec_time = 921
>>
>> My guess is that the task is not running as a real-time task. Do I need
>> to define any other parameter for LITMUS?
>>
>> The application source code and the kernel config files are attached on
>> this email.
>>
>> Thanks in advance,
>> Giovani
>>
>>
>> _______________________________________________
>> litmus-dev mailing list
>> litmus-dev at lists.litmus-rt.org
>> https://lists.litmus-rt.org/listinfo/litmus-dev
>>
>>
>
> _______________________________________________
> litmus-dev mailing list
> litmus-dev at lists.litmus-rt.org
> https://lists.litmus-rt.org/listinfo/litmus-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.litmus-rt.org/pipermail/litmus-dev/attachments/20120425/b1a0a692/attachment.html>


More information about the litmus-dev mailing list