<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Monospace;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EstiloDeEmail19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=PT-BR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Hi Mathew and Joel,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>On the past, I’ve used the following code to get individual task usage and monitor tasks behavior through time. It’s completely based on rtems_cpu_usage_report_with_plugin and I know it’s not the best way to do it, but worked for me </span><span lang=EN-US style='font-family:"Segoe UI Emoji",sans-serif;mso-fareast-language:EN-US'>😊</span><span lang=EN-US style='mso-fareast-language:EN-US'>.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Fabrício.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>/**</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'> * Returns the task usage in us. If the taskId is zero, returns the time since boot.</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>* Code based on ‘rtems_cpu_usage_report_with_plugin’.</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'> **/</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> <b>TasksStatusList::<span style='background:silver;mso-highlight:silver'>GetCpuUsagePerTask</span></b>(</span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>const</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> rtems_id &taskId)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>{</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>if</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (taskId == 0)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>struct</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>timespec</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> uptime;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>struct</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>timespec</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> total;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#642880;mso-fareast-language:EN-US'>rtems_clock_get_uptime</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>(&uptime);</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#642880;mso-fareast-language:EN-US'>_Timespec_Subtract</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>(&CPU_usage_Uptime_at_last_reset, &uptime, &total);</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> totalCpuUsageInUs = (total.</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>tv_sec</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> * </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>static_cast</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'><</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>>(1000000)) + (total.</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>tv_nsec</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> / </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>static_cast</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'><</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>>(1000));</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>return</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> totalCpuUsageInUs;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                }</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>else</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>Objects_Information</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> *ptObjInformation = NULL;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>Thread_Control</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                        *ptThread = NULL;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>Thread_CPU_usage_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> timeRan;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>for</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint32_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> i = 1; i <= OBJECTS_APIS_LAST; i++)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>if</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (!_Objects_Information_table[i])</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               </span><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>{</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>continue</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>; </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>// that’s ugly, but it works</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               }</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               ptObjInformation = _Objects_Information_table[i][1];</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>if</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (ptObjInformation != NULL)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>for</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint32_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> j = 1; j <= ptObjInformation-></span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>maximum</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>; j++)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                               {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               ptThread = </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>reinterpret_cast</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'><</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>Thread_Control</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> *>(ptObjInformation-></span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>local_table</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>[j]);</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               </span><b><span style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>if</span></b><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (ptThread == NULL)</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               {</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                                               </span><b><span style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>continue</span></b><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>; </span><span style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>// still ugly, still works</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>// if the caller task asks for its own cpu usage, the time since the last context switch will not be computed</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>if</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> (ptThread-></span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>Object</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>.</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>id</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> == taskId)</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               {</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                                              timeRan = ptThread-></span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#0000C0;mso-fareast-language:EN-US'>cpu_time_used</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>;</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                                              </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> cpuUsageInUs = (_Timestamp_Get_seconds(&timeRan) * </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>static_cast</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'><</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>>(1000000)) + (_Timestamp_Get_nanoseconds(&timeRan) / </span><b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>static_cast</span></b><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'><</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#005032;mso-fareast-language:EN-US'>uint64_t</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>>(1000));</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                                              </span><b><span style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>return</span></b><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> cpuUsageInUs;</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                                               }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                                               }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                                               }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:#3F7F5F;mso-fareast-language:EN-US'>// if the rtemsId doesn’t exist...</span><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                               </span><b><span style='font-size:8.0pt;font-family:Monospace;color:#7F0055;mso-fareast-language:EN-US'>return</span></b><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'> 0;</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>                }</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:8.0pt;font-family:Monospace;color:black;mso-fareast-language:EN-US'>}</span><span style='font-size:8.0pt;font-family:Monospace;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal><span style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b>De:</b> users [mailto:users-bounces@rtems.org] <b>Em nome de </b>Joel Sherrill<br><b>Enviada em:</b> quinta-feira, 12 de julho de 2018 11:37<br><b>Para:</b> Mathew Benson <mbenson@windhoverlabs.com><br><b>Cc:</b> RTEMS <rtems-users@rtems.org><br><b>Assunto:</b> Re: CPU utilization<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span lang=EN-US>On Tue, Jul 10, 2018 at 2:30 PM, Mathew Benson <</span><a href="mailto:mbenson@windhoverlabs.com" target="_blank"><span lang=EN-US>mbenson@windhoverlabs.com</span></a><span lang=EN-US>> wrote:<o:p></o:p></span></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><div><p class=MsoNormal><span lang=EN-US>What would be the recommend way to read CPU utilization?  Am I correct in saying, the best way would be to call rtems_cpu_usage_report_with_plugin()?  Its ill advised to access the private symbols utilized by the rtems_cpu_usage_report_with_plugin() call directly, right?  Is there another function that I can call to return a structure rather than parsing it with the rtems_printer plugin?  I haven't dug into the rtems_printer object yet, but I'm assuming I could use it and parse a string sent to it.<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='color:#888888'><o:p> </o:p></span></p></div></div></blockquote><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>Yes. You could use the printer_object passed in to parse it. <o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>There isn't a call to get this information (yet) and similarly, there isn't an<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>API to get the stack usage. <o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>Proposals and code welcomed. :)<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>--joel<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US> <o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><div><p class=MsoNormal><span lang=EN-US style='color:#888888'><br>-- <o:p></o:p></span></p><div><div><div><div><div><div><div><p class=MsoNormal><b><span lang=EN-US style='color:#888888'>Mathew Benson</span></b><span lang=EN-US style='color:#888888'><o:p></o:p></span></p></div><p class=MsoNormal><span lang=EN-US style='color:#888888'>CEO | Chief Engineer<o:p></o:p></span></p></div><p class=MsoNormal><span lang=EN-US style='color:#888888'>Windhover Labs, LLC<br>832-640-4018<br><br></span><span style='color:#888888'><img border=0 width=250 height=39 style='width:2.6041in;height:.4062in' id="_x0000_i1025" src="https://drive.google.com/a/windhoverlabs.com/uc?id=1cLDczWESrU667xKgEJlFhHa2yjq5UVhJ&export=download" alt="https://drive.google.com/a/windhoverlabs.com/uc?id=1cLDczWESrU667xKgEJlFhHa2yjq5UVhJ&export=download"></span><span lang=EN-US style='color:#888888'><o:p></o:p></span></p></div><p class=MsoNormal style='margin-bottom:12.0pt'><a href="http://www.windhoverlabs.com" target="_blank"><span lang=EN-US>www.windhoverlabs.com</span></a><span lang=EN-US style='color:#888888'><o:p></o:p></span></p></div></div></div></div></div></div><p class=MsoNormal><span lang=EN-US><br>_______________________________________________<br>users mailing list<br></span><a href="mailto:users@rtems.org"><span lang=EN-US>users@rtems.org</span></a><span lang=EN-US><br></span><a href="http://lists.rtems.org/mailman/listinfo/users" target="_blank"><span lang=EN-US>http://lists.rtems.org/mailman/listinfo/users</span></a><span lang=EN-US><o:p></o:p></span></p></blockquote></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></div></div></body></html>