NSH: ps command will show CPU if SMP is enabled

This commit is contained in:
Gregory Nutt 2016-02-19 15:33:32 -06:00
parent 7537a963b4
commit c6ac4d2581
2 changed files with 29 additions and 1 deletions

View File

@ -1550,4 +1550,6 @@
table (2016-02-08). table (2016-02-08).
* apps/nshlib: Add an 'arp' command that will support access to * apps/nshlib: Add an 'arp' command that will support access to
the OS ARP table (2016-02-08). the OS ARP table (2016-02-08).
* apps/nshlib: 'ps' command will show CPU if SMP is enabled
(2016-02-19).

View File

@ -90,8 +90,11 @@ struct nsh_taskstatus_s
#ifdef HAVE_GROUPID #ifdef HAVE_GROUPID
FAR const char *td_groupid; /* Group ID */ FAR const char *td_groupid; /* Group ID */
#else #else
FAR const char *td_ppid; /* Parent thread ID */ FAR const char *td_ppid; /* Parent thread ID */
#endif #endif
#endif
#ifdef CONFIG_SMP
FAR const char *td_cpu; /* CPU */
#endif #endif
FAR const char *td_state; /* Thread state */ FAR const char *td_state; /* Thread state */
FAR const char *td_event; /* Thread wait event */ FAR const char *td_event; /* Thread wait event */
@ -116,6 +119,9 @@ static const char g_groupid[] = "Group:";
static const char g_ppid[] = "PPID:"; static const char g_ppid[] = "PPID:";
#endif #endif
#endif #endif
#ifdef CONFIG_SMP
static const char g_cpu[] = "CPU:";
#endif
static const char g_state[] = "State:"; static const char g_state[] = "State:";
static const char g_flags[] = "Flags:"; static const char g_flags[] = "Flags:";
static const char g_priority[] = "Priority:"; static const char g_priority[] = "Priority:";
@ -190,6 +196,15 @@ static void nsh_parse_statusline(FAR char *line,
#endif #endif
#endif #endif
#ifdef CONFIG_SMP
else if (strncmp(line, g_cpu, strlen(g_cpu)) == 0)
{
/* Save the current CPU */
status->td_cpu = nsh_trimspaces(&line[12]);
}
#endif
else if (strncmp(line, g_state, strlen(g_state)) == 0) else if (strncmp(line, g_state, strlen(g_state)) == 0)
{ {
FAR char *ptr; FAR char *ptr;
@ -279,6 +294,9 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
#else #else
status.td_ppid = ""; status.td_ppid = "";
#endif #endif
#endif
#ifdef CONFIG_SMP
status.td_cpu = "";
#endif #endif
status.td_state = ""; status.td_state = "";
status.td_event = ""; status.td_event = "";
@ -347,6 +365,10 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
#endif #endif
#endif #endif
#ifdef CONFIG_SMP
nsh_output(vtbl, "%3s ", status.td_cpu);
#endif
nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ", nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ",
status.td_priority, status.td_policy, status.td_type, status.td_priority, status.td_policy, status.td_type,
status.td_flags, status.td_state, status.td_event); status.td_flags, status.td_state, status.td_event);
@ -446,6 +468,10 @@ int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#endif #endif
#endif #endif
#ifdef CONFIG_SMP
nsh_output(vtbl, "%3s ", "CPU");
#endif
nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ", nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ",
"PRI", "POLICY", "TYPE", "NPX", "STATE", "EVENT"); "PRI", "POLICY", "TYPE", "NPX", "STATE", "EVENT");