<div dir="ltr">Hi,<div><br></div><div>About the code:</div><div><br></div><div> T_busy(T_get_one_clock_tick_busy() * SOME_CONSTANT);</div><div><br></div><div>does this support context switch? If task A executing on CPU 1 gets preempted while executing this (by task B) and then comes back on CPU 1 after some time (when task B finishes its execution), would task A finish its execution of this function - as nothing happened? </div><div><br></div><div>So, if we ask Task A to run T_busy for 5000 ticks, and it gets preempted after 3000 ticks and maybe moves to another CPU, would it run for the remaining 2000 ticks on that CPU? </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 21, 2021 at 9:50 AM Richi Dubey <<a href="mailto:richidubey@gmail.com">richidubey@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Thanks for your quick responses!</div><div><br></div><div>The suggestion certainly is helpful, we are going to try it out. I'll post the result here.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 20, 2021 at 8:57 PM Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 20, 2021 at 10:05 AM <<a href="mailto:Jan.Sommer@dlr.de" target="_blank">Jan.Sommer@dlr.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="DE">
<div>
<p class="MsoNormal"><span lang="EN-US">Hi Richi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">You can checkout the T_busy functions here:
<a href="https://git.rtems.org/rtems/tree/cpukit/include/rtems/test.h#n2390" target="_blank">https://git.rtems.org/rtems/tree/cpukit/include/rtems/test.h#n2390</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10pt;font-family:"Courier New"">uint_fast32_t T_get_one_clock_tick_busy(void)
</span><span lang="EN-US">gives you the busy count for one tick.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">You can then calculate the number of cycles you need to wait for you desired certain time and pass it to:
</span><code><span lang="EN-US" style="font-size:10pt">void T_busy(uint_fast32_t)</span></code><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This should give you comparably accurate results over different platforms.</span></p></div></div></blockquote><div><br></div><div>That's certainly a better method than what I suggested.</div><div><br></div><div>--joel </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="DE"><div><p class="MsoNormal"><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Best regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> Jan<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0cm 0cm 0cm 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> devel <<a href="mailto:devel-bounces@rtems.org" target="_blank">devel-bounces@rtems.org</a>>
<b>On Behalf Of </b>Richi Dubey<br>
<b>Sent:</b> Thursday, May 20, 2021 4:53 PM<br>
<b>To:</b> <a href="mailto:rtems-devel@rtems.org" target="_blank">rtems-devel@rtems.org</a> <<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a>><br>
<b>Subject:</b> Writing code that takes time to run<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">Hi,<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">We are thinking of writing a piece of code that takes some time to run (it would be amazing if it takes around 2 secs to run on hardware, but we would be happy with something that takes a few milliseconds as well). <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">We tried writing this:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"> for(int i = 0; i<10000000; ++i){<br>
fib2 = fib0 + fib1;<br>
fib0 = fib1;<br>
fib1 = fib2;<br>
}<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">which takes few milliseconds when tested on qemu, but only takes few microseconds on a real board. Do you have any suggestions of what else we can do?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">We want to write a code that is context switch safe (so, we can't simply check the time before a loop, run an infinite loop that keeps checking current time and stops after a few seconds - because this logic would fail
if there happens a context switch inside the loop and the task gets the control back after a few seconds). We also don't want to do a wake_after() since we want the task to be running on the cpu during the entire time (it is okay if the task gets preempted due
to a higher priority process), and not voluntarily giving the control to some other task.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Any suggestions? The aim is to see the affect of a task getting removed from the cpu due to task shifting by the newly arrived task (in strong apa vs non task shifting scheduler).<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal">Thank you.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a></blockquote></div></div>
</blockquote></div>
</blockquote></div>