<div class="gmail_extra"><div class="gmail_quote">2012/4/25 Giovani Gracioli <span dir="ltr"><<a href="mailto:giovanig@gmail.com" target="_blank">giovanig@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra">So is there a way to ensure that the task will execute for its correct execution time?</div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra"><br></div></font></span><div class="gmail_extra">
<span class="HOEnZb"><font color="#888888">Giovani</font></span><div><div class="h5"><br></div></div></div></blockquote><div><br>Glenn is right, the problem is because you are forcing the loop to run for WCET units of time. rtspin, for example, uses 90%. <br>
<br>Also, I'm not sure if all scheduling algorithms works with
PRECISE_ENFORCEMENT on. But you can check if the tasks are executing for the right time using st_trace and unit-trace.<br>
Have a look at Recording Scheduling Traces: <a href="http://www.cs.unc.edu/~anderson/litmus-rt/doc/tracing.html">http://www.cs.unc.edu/~anderson/litmus-rt/doc/tracing.html</a><br>
<br>
Could you change<br>
sleep_next_period();<br>to:<br> wait_for_job_release(0); ?<br><br>And then use st_trace and unit-trace (visual mode) to visualize the results.<br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Wed, Apr 25, 2012 at 5:53 PM, Glenn Elliott <span dir="ltr"><<a href="mailto:gelliott@cs.unc.edu" target="_blank">gelliott@cs.unc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF"><div>A word of warning about using budget enforcement: There is currently no way for the kernel to report back to the user program that the program has exceeded its budget. Your program will simply resume execution from where it left off upon next job release, and not start a new program-level job.</div>
<span><font color="#888888"><div><br></div><div>-Glenn<br><br></div></font></span></div></blockquote></div></div></div></div></blockquote><div><br>Glenn,<br>
<br>
I saw that we can use wait_for_job_release() instead,
because it compares the number of the current job and the job to be
released.<br>
If the program is late, it checks the number of the job and doesn't block (as sleep_next_period() would do).<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_extra"><div><div class="h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF"><span><font color="#888888"><div>
<br></div></font></span><div><div><div><br>On Apr 25, 2012, at 3:58 PM, Felipe Cerqueira <<a href="mailto:felipeqcerqueira@gmail.com" target="_blank">felipeqcerqueira@gmail.com</a>> wrote:<br>
<br></div><div></div><blockquote type="cite"><div><div class="gmail_extra">Hi Giovani,<br><br>I've already faced something like that. The problem is that it's not safe to measure time within the application.<br><br>
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: <br>
<br> loop_start = read_tsc_us(); // reads from the TSC and converts to microsecond<br>
tmp += loop_once();<br> -> Suppose the task is preempted right here<br> loop_end = read_tsc_us();<br><br>Also, system interrupts may have ocurred between the measurements.<br><br>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.<br>
<br>The task will run according to the execution time you provided at the initialization, but you can't check that via the application.<br>The only thing you can change is the WCET enforcement:<br><br>sporadic_task_ns(ctx->exec_time * 1000, ctx->period * 1000, 0, 0, RT_CLASS_HARD, QUANTUM_ENFORCEMENT, 0);<br>
<br>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.<br>
<br>Best Regards,<br>Felipe<br><br><div class="gmail_quote">2012/4/25 Giovani Gracioli <span dir="ltr"><<a href="mailto:giovanig@gmail.com" target="_blank">giovanig@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br><br>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:<br><br>//exec_time in microseconds<br>
int loop_for(unsigned int exec_time) <br>{<br> int tmp = 0;<br> unsigned int elapsed = 0;<br> unsigned long long loop_start = 0, loop_end = 0;<br><br> while(elapsed < exec_time) {<br> loop_start = read_tsc_us(); // reads from the TSC and converts to microsecond<br>
tmp += loop_once();<br> loop_end = read_tsc_us(); <br> elapsed = elapsed + (loop_end - loop_start);<br> } <br><br> printf("elapsed = %d, exec_time = %d\n", elapsed, exec_time);<br>
<br> return tmp;<br>}<br>
<br>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:<br>
<br>elapsed = 13003, exec_time = 921<br>elapsed = 12999, exec_time = 921<br>elapsed = 13003, exec_time = 921<br>elapsed = 13007, exec_time = 921<br>elapsed = 13007, exec_time = 921<br>elapsed = 12998, exec_time = 921<br>
elapsed = 12995, exec_time = 921<br>
elapsed = 12999, exec_time = 921<br>elapsed = 12990, exec_time = 921<br>elapsed = 921, exec_time = 921<br>elapsed = 13002, exec_time = 921<br><br>My guess is that the task is not running as a real-time task. Do I need to define any other parameter for LITMUS?<br>
<br>The application source code and the kernel config files are attached on this email.<br><br>Thanks in advance,<br>Giovani<br><br>
<br>_______________________________________________<br>
litmus-dev mailing list<br>
<a href="mailto:litmus-dev@lists.litmus-rt.org" target="_blank">litmus-dev@lists.litmus-rt.org</a><br>
<a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>litmus-dev mailing list</span><br><span><a href="mailto:litmus-dev@lists.litmus-rt.org" target="_blank">litmus-dev@lists.litmus-rt.org</a></span><br>
<span><a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a></span><br></div></blockquote></div></div></div><br>_______________________________________________<br>
litmus-dev mailing list<br>
<a href="mailto:litmus-dev@lists.litmus-rt.org" target="_blank">litmus-dev@lists.litmus-rt.org</a><br>
<a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
litmus-dev mailing list<br>
<a href="mailto:litmus-dev@lists.litmus-rt.org">litmus-dev@lists.litmus-rt.org</a><br>
<a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
<br></blockquote></div><br></div>