NSH: ps command will show CPU if SMP is enabled
This commit is contained in:
parent
7537a963b4
commit
c6ac4d2581
@ -1550,4 +1550,6 @@
|
||||
table (2016-02-08).
|
||||
* apps/nshlib: Add an 'arp' command that will support access to
|
||||
the OS ARP table (2016-02-08).
|
||||
* apps/nshlib: 'ps' command will show CPU if SMP is enabled
|
||||
(2016-02-19).
|
||||
|
||||
|
@ -92,6 +92,9 @@ struct nsh_taskstatus_s
|
||||
#else
|
||||
FAR const char *td_ppid; /* Parent thread ID */
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_SMP
|
||||
FAR const char *td_cpu; /* CPU */
|
||||
#endif
|
||||
FAR const char *td_state; /* Thread state */
|
||||
FAR const char *td_event; /* Thread wait event */
|
||||
@ -116,6 +119,9 @@ static const char g_groupid[] = "Group:";
|
||||
static const char g_ppid[] = "PPID:";
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_SMP
|
||||
static const char g_cpu[] = "CPU:";
|
||||
#endif
|
||||
static const char g_state[] = "State:";
|
||||
static const char g_flags[] = "Flags:";
|
||||
static const char g_priority[] = "Priority:";
|
||||
@ -190,6 +196,15 @@ static void nsh_parse_statusline(FAR char *line,
|
||||
#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)
|
||||
{
|
||||
FAR char *ptr;
|
||||
@ -279,6 +294,9 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
|
||||
#else
|
||||
status.td_ppid = "";
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_SMP
|
||||
status.td_cpu = "";
|
||||
#endif
|
||||
status.td_state = "";
|
||||
status.td_event = "";
|
||||
@ -347,6 +365,10 @@ static int ps_callback(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
nsh_output(vtbl, "%3s ", status.td_cpu);
|
||||
#endif
|
||||
|
||||
nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ",
|
||||
status.td_priority, status.td_policy, status.td_type,
|
||||
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
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
nsh_output(vtbl, "%3s ", "CPU");
|
||||
#endif
|
||||
|
||||
nsh_output(vtbl, "%3s %-8s %-7s %3s %-8s %-9s ",
|
||||
"PRI", "POLICY", "TYPE", "NPX", "STATE", "EVENT");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user