diff --git a/ChangeLog b/ChangeLog index 47354c5a4a..4506db9338 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11496,3 +11496,6 @@ actions from the TCB to the group structure. Signal handlers are not per thread but, rather, per task group. I know, I preferred it the other way too, but this is more compliant with POSIX (2016-02-18). + * fs/ procfs/fs_procfsproc.c: Add support for showing CPU if SMP is + is enabled (2016-02-19). + diff --git a/TODO b/TODO index 31e12cfeeb..9bf3e7ede3 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ NuttX TODO List (Last updated February 18, 2016) +NuttX TODO List (Last updated February 18, 2016) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -1621,7 +1622,12 @@ o Linux/Cywgin simulation (arch/sim) not an issue with the NuttX SMP logic but more likely some chaos in the pthread controls. I have seen similar such strange behavior other times that I have tried to use setjmp/longmp from a signal - handler! + handler! Like when I tried to implement simulated interrupts + using signals. + + Apparently, if longjmp is invoked from the context of a signal + handler, the result is undefined: + http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1318.htm You can enable SMP for ostest configuration by enabling: diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index e90d46ef08..d47da8b67b 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -375,6 +375,7 @@ static FAR const struct proc_node_s *proc_findnode(FAR const char *relpath) * Type: xxxxxxx {Task, pthread, Kthread, Invalid} * PPID: xxxxx Parent thread ID * Group: xxxxx Group ID + * CPU: xxx CPU (CONFIG_SMP only) * State: xxxxxxxx,xxxxxxxxx {Invalid, Waiting, Ready, Running, Inactive}, * {Unlock, Semaphore, Signal, MQ empty, MQ full} * Flags: xxx N,P,X @@ -461,6 +462,30 @@ static ssize_t proc_status(FAR struct proc_file_s *procfile, } #endif +#ifdef CONFIG_SMP + if (tcb->task_state >= FIRST_ASSIGNED_STATE && + tcb->task_state <= LAST_ASSIGNED_STATE) + { + linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%d\n", "CPU:", + tcb->cpu); + } + else + { + linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s---\n", "CPU:"); + } + + copysize = procfs_memcpy(procfile->line, linesize, buffer, remaining, &offset); + + totalsize += copysize; + buffer += copysize; + remaining -= copysize; + + if (totalsize >= buflen) + { + return totalsize; + } +#endif + /* Show the thread state */ linesize = snprintf(procfile->line, STATUS_LINELEN, "%-12s%s\n", "State:", diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index e7a8d5c26f..65722e23b0 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -222,6 +222,8 @@ typedef enum tstate_e tstate_t; #define FIRST_READY_TO_RUN_STATE TSTATE_TASK_READYTORUN #define LAST_READY_TO_RUN_STATE TSTATE_TASK_RUNNING +#define FIRST_ASSIGNED_STATE TSTATE_TASK_ASSIGNED +#define LAST_ASSIGNED_STATE TSTATE_TASK_RUNNING #define FIRST_BLOCKED_STATE TSTATE_TASK_INACTIVE #define LAST_BLOCKED_STATE (NUM_TASK_STATES-1)