[PATCH v2] libmisc/top: Fix the idle time and priorities on SMP
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Dec 13 07:08:23 UTC 2019
From: Chris Johns <chrisj at rtems.org>
- This patch is based on the patch attached to #3552 submitted
by jameszxj.
Closes #3552
---
cpukit/libmisc/cpuuse/cpuusagetop.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c
index 96e364bf93..146b9801a4 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -36,10 +36,12 @@
#include <rtems/malloc.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/protectedheap.h>
+#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/todimpl.h>
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
+#include <rtems/rtems/tasksimpl.h>
#include "cpuuseimpl.h"
@@ -194,10 +196,10 @@ task_usage(Thread_Control* thread, void* arg)
_Timestamp_Add_to(&data->total, &usage);
_Timestamp_Add_to(&data->current, ¤t);
- if (thread->Object.id == 0x09010001)
+ if (thread->is_idle)
{
- data->idle = usage;
- data->current_idle = current;
+ data->idle += usage;
+ data->current_idle += current;
}
/*
@@ -421,9 +423,13 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
for (i = 0; i < data->task_count; i++)
{
- Thread_Control* thread = data->tasks[i];
- Timestamp_Control usage;
- Timestamp_Control current_usage;
+ Thread_Control* thread = data->tasks[i];
+ Timestamp_Control usage;
+ Timestamp_Control current_usage;
+ Thread_queue_Context queue_context;
+ const Scheduler_Control *scheduler;
+ Priority_Control real_priority;
+ Priority_Control priority;
if (thread == NULL)
break;
@@ -444,12 +450,19 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
if (name[0] == '\0')
snprintf(name, sizeof(name) - 1, "(%p)", thread->Start.Entry.Kinds.Numeric.entry);
+ _Thread_queue_Context_initialize(&queue_context);
+ _Thread_Wait_acquire(thread, &queue_context);
+ scheduler = _Thread_Scheduler_get_home(thread);
+ real_priority = thread->Real_priority.priority;
+ priority = _Thread_Get_priority(thread);
+ _Thread_Wait_release(thread, &queue_context);
+
rtems_printf(data->printer,
- " 0x%08" PRIx32 " | %-19s | %3" PRId64 " | %3" PRId64 " | ",
+ " 0x%08" PRIx32 " | %-19s | %3" PRId32 " | %3" PRId32 " | ",
thread->Object.id,
name,
- _Thread_Get_unmapped_real_priority(thread),
- _Thread_Get_unmapped_priority(thread));
+ _RTEMS_Priority_From_core(scheduler, real_priority),
+ _RTEMS_Priority_From_core(scheduler, priority));
usage = data->usage[i];
current_usage = data->current_usage[i];
--
2.16.4
More information about the devel
mailing list