This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

xdc.runtime.Timestamp in a multi-threaded system

Can anyone tell me if xdc.runtime.Timestamp is aware of the thread it is running in?

I have a lower frequency lower priority thread and a higher frequency higher priority thread.

If I measure an elapsed time in the lower freq thread (by two calls to xdc.runtime.Timestamp) will it include time taken in the higher freq thread and task switching etc?

Thanks.

Michael.

  • Hi Michael,

    xdc.runtime.Timestamp is not thread aware. So the delta between two calls to Timestamp_get32 (or get64) is the true time delta, regardless of what was actually running (e.g. Tasks, Swis or Hwis).

    Todd

  • Sorry for the delay in responding.

    Thanks for your answer.

    Do you have any advice for me in terms of what I need to do to get time elapsed only within a thread?

    Is there any way to get to record timestamps when a task switch occurs?

    Thanks

    Michael.

  • Michael,

    If you are interested in collecting timestamps on Task switches you can use Task hooks.  Section 3.5.5 of Bios_User_Guide.pdf describes using Task hooks, and has a code example in section 3.5.5.6.  You can do something similar to that example, and save or print timestamps on Task switches.  There is a similar mechanism for Swis, with Begin and End function hooks.  

    Note that these hooks don’t get invoked on normal preemption, for example when a Hwi preempts a Task.  It is a similar case for a Swi preempting a Task, the Task switch hook will not be invoked when execution temporarily transfers to a Swi.  So, if you are collecting timestamps based solely upon Task switching, those values will include time spent in any preempting Swi or Hwi as well. 

    If you haven’t seen it, Chapter 8 of the same user guide describes built-in instrumentation mechanisms that allow you to profile and view application execution...

    Scott

  • Just the info I was looking for,

    Thanks Scott.