From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 16 Feb 2021 08:03:22 -0600 (CST) From: Per Oberg Message-ID: <2090142485.8963531.1613484202750.JavaMail.zimbra@wolfram.com> In-Reply-To: References: Subject: Re: Execution time MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai ----- Den 16 feb 2021, p=C3=A5 kl 12:34, xenomai xenomai@xenomai.org skrev: > hi, I'm doing some tests. I'm measuring the execution time of a task. the > task takes about 10us to complete. But I am noticing that it takes even > just over 5us at times. I therefore don't have a constant running time. > It's normal? maybe because the precision is of the order of micro seconds= ? It depends on=20 * The task, and it's priority * How you are measuring time * What hardware you are using * What else is happening in the system If it's a fairly simple task it shouldn't vary to much, but if the task may= or may not trigger some extra action. Modern complex CPU's have a lot of f= eatures that speeds things up for repetitive code. For example, the time of= reading a memory buffer may depend on what was read before.=20 If there are other high-priority tasks going on, or perhaps a hardware inte= rrupt coming in your tasks execution may be delayed.=20 Time measurement may differ depending on what functions you use. Some call = the Linux clock, some use Xenomai based clocks. Depending on the hardware you may or may not be able to control exactly wha= t is happening in your system. This is strictly from memory, but SMI interr= upts on the PC platform is one such thing that is out of your hands. Raspbe= rry Pi is another can of worms if I recall correctly. Firstly, ARM has regu= lar interrupts and fast interrupts and I am not sure where Xenomai makes th= e cut. Then there is the broadcom chip of the RPi that I think has some han= dling of the USB that you don't have control over.=20 Per =C3=96berg=20