Re: CPU utilization

2018-07-12 Thread Mathew Benson
I like this idea.  I signed up for the mailing list.  I'll try to submit
something in the next few days.  Thanks.

On Thu, Jul 12, 2018 at 12:56 PM, Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> - Am 12. Jul 2018 um 19:48 schrieb Mathew Benson
> mathew.ben...@gmail.com:
>
> > I assume symbols prefixed with "_" are to be considered part of the
> private
> > API.  What are the guidelines and legalities, if any, of bringing in
> these
> > private symbols into our own code?
>
> Functions, variables, and so on starting with an underscore "_" should
> never be used by application code. If a certain functionality is not
> provided by a public API in RTEMS, then a public API for this functionality
> should be proposed to de...@rtems.org (or via a ticket). It should be
> documented and tested.
> ___
> users mailing list
> users@rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>



-- 
*Mathew Benson*
CEO | Chief Engineer
Windhover Labs, LLC
832-640-4018


www.windhoverlabs.com
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Re: CPU utilization

2018-07-12 Thread Sebastian Huber
- Am 12. Jul 2018 um 19:48 schrieb Mathew Benson mathew.ben...@gmail.com:

> I assume symbols prefixed with "_" are to be considered part of the private
> API.  What are the guidelines and legalities, if any, of bringing in these
> private symbols into our own code?

Functions, variables, and so on starting with an underscore "_" should never be 
used by application code. If a certain functionality is not provided by a 
public API in RTEMS, then a public API for this functionality should be 
proposed to de...@rtems.org (or via a ticket). It should be documented and 
tested.
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users


Re: CPU utilization

2018-07-12 Thread Mathew Benson
I assume symbols prefixed with "_" are to be considered part of the private
API.  What are the guidelines and legalities, if any, of bringing in these
private symbols into our own code?

On Thu, Jul 12, 2018 at 11:10 AM, Fabrício de Novaes Kucinskis <
fabricio.kucins...@inpe.br> wrote:

> Hi Mathew and Joel,
>
>
>
> 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 .
>
>
>
> Regards,
>
>
>
> Fabrício.
>
>
>
> /**
>
> * Returns the task usage in us. If the taskId is zero, returns the time
> since boot.
>
> * Code based on ‘rtems_cpu_usage_report_with_plugin’.
>
> **/
>
> uint64_t *TasksStatusList::GetCpuUsagePerTask*(*const* rtems_id )
>
> {
>
> *if* (taskId == 0)
>
> {
>
>*struct* timespec uptime;
>
>*struct* timespec total;
>
>
>
>*rtems_clock_get_uptime*();
>
>
> *_Timespec_Subtract*(_usage_Uptime_at_last_reset,
> , );
>
>
>
>uint64_t totalCpuUsageInUs = (total.tv_sec
> * *static_cast*(100)) + (total.tv_nsec / *static_cast*<
> uint64_t>(1000));
>
>
>
>*return* totalCpuUsageInUs;
>
> }
>
> *else*
>
> {
>
>Objects_Information *ptObjInformation =
> NULL;
>
>Thread_Control
> *ptThread = NULL;
>
>Thread_CPU_usage_t timeRan;
>
>
>
>*for* (uint32_t i = 1; i <=
> OBJECTS_APIS_LAST; i++)
>
>{
>
>*if*
> (!_Objects_Information_table[i])
>
>{
>
>*continue*;
> // that’s ugly, but it works
>
>}
>
>
>
>ptObjInformation =
> _Objects_Information_table[i][1];
>
>
>
>*if* (ptObjInformation !=
> NULL)
>
>{
>
>*for* (
> uint32_t j = 1; j <= ptObjInformation->maximum; j++)
>
>{
>
>
> ptThread = *reinterpret_cast*(ptObjInformation->local_
> table[j]);
>
>
>
>
> *if* (ptThread == NULL)
>
>
> {
>
>
>  *continue*; // still
> ugly, still works
>
>
> }
>
>
>
>
> // if the caller task asks for its own cpu usage, the time since the last
> context switch will not be computed
>
>
> *if* (ptThread->Object.id == taskId)
>
>
> {
>
>
>   timeRan = ptThread->cpu_time_used;
>
>
>
>
>   uint64_t cpuUsageInUs =
> (_Timestamp_Get_seconds() * *static_cast*(100)) +
> (_Timestamp_Get_nanoseconds() / *static_cast*(1000));
>
>
>
>
>   *return* cpuUsageInUs;
>
>
> }
>
>    }
>
>}
>
>}
>
>
>
>// if the rtemsId doesn’t exist...
>
>*return* 0;
>
> }
>
> }
>
>
>
> *De:* users [mailto:users-boun...@rtems.org] *Em nome de *Joel Sherrill
> *Enviada em:* quinta-feira, 12 de julho de 2018 11:37
> *Para:* Mathew Benson 
> *Cc:* RTEMS 
> *Assunto:* Re: CPU utilization
>
>
>
>
>
>
>
> On Tue, Jul 10, 2018 at 2:30 PM, Mathew Benson 
> wrote:
>
> 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 ass