[riot-devel] Compute the time elapsed when switching between two threads

Julien Gomez julien.gomez at student.uclouvain.be
Wed Nov 21 11:31:33 CET 2018


Hi Joakim,

Indeed, using external equipment like an oscillograph was the first thing I did.

But I am looking to compute the context switching time only with software.


I am pretty sure I will have to tweak the kernel to get such measurements 😞 And even doing so, I will not have the closest value to the real elapsed time.


Regards,
Julien

________________________________
De : devel <devel-bounces at riot-os.org> de la part de Joakim Nohlgård <joakim.nohlgard at eistec.se>
Envoyé : jeudi 15 novembre 2018 18:38:43
À : RIOT OS kernel developers
Objet : Re: [riot-devel] Compute the time elapsed when switching between two threads

Would you be able to get the measurements you are looking for using this approach instead?
The low priority thread is toggling a gpio pin in a tight loop. The other thread toggles a different pin as soon as it is resumed. You would need external equipment to get the time between the two, but it should give a fairly accurate measurement for a single context switch.
/Joakim

Den tor 15 nov. 2018 17:49 skrev Julien Gomez <julien.gomez at student.uclouvain.be<mailto:julien.gomez at student.uclouvain.be>>:

Hi Gaëtan,

Thank you for your answer!

I did look at this test and it counts the number of context switches between two threads of the same priority in one second.

What I want is something more abstract (any thread, any priority). To reformulate my question, let's assume I have two threads. It doesn't matter what they are doing. One of the threads will be interrupted by the other and a context switch will occur. What I want to know is how much time is spent in the context switching.

I don't think this is possible at the application-level.

Regards,
Julien

________________________________
De : Gaëtan Harter <gaetan.harter at fu-berlin.de<mailto:gaetan.harter at fu-berlin.de>>
Envoyé : jeudi 15 novembre 2018 17:28:16
À : devel at riot-os.org<mailto:devel at riot-os.org>; Julien Gomez
Objet : Re: [riot-devel] Compute the time elapsed when switching between two threads

Hi Julien,

I think this test should be doing what you want, I did not look at it
just knew it existed.


https://github.com/RIOT-OS/RIOT/tree/master/test/bench_thread_yield_pingpong



Regards,
Gaëtan - cladmi

On 15.11.18 16:41, Julien Gomez wrote:
> Hello fellow developers !
>
> I have a simple question: How one could compute the time elapsed when switching from thread A to thread B?
>
> Any advice or lead is welcome!
>
> Regards,
> Julien
>
>
> _______________________________________________
> devel mailing list
> devel at riot-os.org<mailto:devel at riot-os.org>
> https://lists.riot-os.org/mailman/listinfo/devel
>
_______________________________________________
devel mailing list
devel at riot-os.org<mailto:devel at riot-os.org>
https://lists.riot-os.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/devel/attachments/20181121/93b0cdc3/attachment.html>


More information about the devel mailing list