critmon: add total time running time of task

PRE-EMPTION   CSECTION      RUN         TIME         PID   DESCRIPTION
0.000000000   0.000000000   0.001237000 28.421047000 0     Idle Task

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2023-04-24 12:36:07 +08:00 committed by David Sidrane
parent 5b2a89e174
commit 3877c31b2f

View File

@ -119,6 +119,7 @@ static int critmon_process_directory(FAR struct dirent *entryp)
FAR char *maxpreemp; FAR char *maxpreemp;
FAR char *maxcrit; FAR char *maxcrit;
FAR char *maxrun; FAR char *maxrun;
FAR char *runtime;
FAR char *endptr; FAR char *endptr;
FILE *stream; FILE *stream;
int len; int len;
@ -229,10 +230,19 @@ static int critmon_process_directory(FAR struct dirent *entryp)
{ {
*maxrun++ = '\0'; *maxrun++ = '\0';
endptr = strchr(maxrun, '\n'); runtime = strchr(maxrun, ',');
if (endptr != NULL) if (runtime != NULL)
{ {
*endptr = '\0'; *runtime++ = '\0';
endptr = strchr(runtime, '\n');
if (endptr != NULL)
{
*endptr = '\0';
}
}
else
{
runtime = "None";
} }
} }
else else
@ -249,11 +259,11 @@ static int critmon_process_directory(FAR struct dirent *entryp)
/* Finally, output the stack info that we gleaned from the procfs */ /* Finally, output the stack info that we gleaned from the procfs */
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
printf("%11s %11s %11s %5s %s\n", printf("%11s %11s %11s %-16s %-5s %s\n",
maxpreemp, maxcrit, maxrun, entryp->d_name, name); maxpreemp, maxcrit, maxrun, runtime, entryp->d_name, name);
#else #else
printf("%11s %11s %5s\n", printf("%11s %11s %11s %16s %5s\n",
maxpreemp, maxcrit, entryp->d_name); maxpreemp, maxcrit, maxrun, runtime, entryp->d_name);
#endif #endif
ret = OK; ret = OK;
@ -374,7 +384,7 @@ static void critmon_global_crit(void)
/* Finally, output the stack info that we gleaned from the procfs */ /* Finally, output the stack info that we gleaned from the procfs */
printf("%11s %11s ----------- ----- CPU %s\n", printf("%11s %11s ----------- ---------------- ---- CPU %s\n",
maxpreemp, maxcrit, cpu); maxpreemp, maxcrit, cpu);
} }
@ -398,9 +408,10 @@ static int critmon_list_once(void)
/* Output a Header */ /* Output a Header */
#if CONFIG_TASK_NAME_SIZE > 0 #if CONFIG_TASK_NAME_SIZE > 0
printf("PRE-EMPTION CSECTION RUN PID DESCRIPTION\n"); printf("PRE-EMPTION CSECTION RUN TIME "
"PID DESCRIPTION\n");
#else #else
printf("PRE-EMPTION CSECTION RUN PID\n"); printf("PRE-EMPTION CSECTION RUN TIME PID\n");
#endif #endif
/* Should global usage first */ /* Should global usage first */