From ccbf514233d9f89ec4623570eecded61bdaab50e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 21 Mar 2016 15:24:15 -0600 Subject: [PATCH] Add task state to information recorded when a task is suspended --- arch | 2 +- fs/procfs/fs_procfsproc.c | 6 +-- include/nuttx/sched_note.h | 14 +++++-- sched/sched/sched_note.c | 78 ++++++++++++++++++-------------------- 4 files changed, 52 insertions(+), 48 deletions(-) diff --git a/arch b/arch index 2a3c96286af..e473d2dfda7 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 2a3c96286af41c261411d9cdd17e98e2ee18dc2e +Subproject commit e473d2dfda7181296f10103bde2323d8df4c2ddb diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c index 720c5174384..eb93fc5a550 100644 --- a/fs/procfs/fs_procfsproc.c +++ b/fs/procfs/fs_procfsproc.c @@ -302,7 +302,7 @@ static const struct proc_node_s * const g_level0info[] = /* This is the list of all group sub-directory nodes */ -static const struct proc_node_s * const g_groupinfo[] = +static FAR const struct proc_node_s * const g_groupinfo[] = { &g_groupstatus, /* Task group status */ &g_groupfd /* Group file descriptors */ @@ -311,7 +311,7 @@ static const struct proc_node_s * const g_groupinfo[] = /* Names of task/thread states */ -static const char *g_statenames[] = +static FAR const char *g_statenames[] = { "Invalid", "Waiting,Unlock", @@ -328,7 +328,7 @@ static const char *g_statenames[] = #endif }; -static const char *g_ttypenames[4] = +static FAR const char *g_ttypenames[4] = { "Task", "pthread", diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h index 7a20e57284a..c21f0400660 100644 --- a/include/nuttx/sched_note.h +++ b/include/nuttx/sched_note.h @@ -107,11 +107,19 @@ struct note_stop_s struct note_common_s nsp_cmn; /* Common note parameters */ }; -/* This is the specific form of the NOTE_SUSPEND/NOTE_RESUME note */ +/* This is the specific form of the NOTE_SUSPEND note */ -struct note_switch_s +struct note_suspend_s { - struct note_common_s nsw_cmn; /* Common note parameters */ + struct note_common_s nsu_cmn; /* Common note parameters */ + uint8_t nsu_state; /* Task state */ +}; + +/* This is the specific form of the NOTE_RESUME note */ + +struct note_resume_s +{ + struct note_common_s nre_cmn; /* Common note parameters */ }; #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION diff --git a/sched/sched/sched_note.c b/sched/sched/sched_note.c index b59e75d713c..2467338946b 100644 --- a/sched/sched/sched_note.c +++ b/sched/sched/sched_note.c @@ -263,45 +263,6 @@ static void note_add(FAR const uint8_t *note, uint8_t notelen) g_note_info.ni_head = head; } -/**************************************************************************** - * Name: sched_note_switch - * - * Description: - * Perform core logic for both sched_note_suspend and sched_note_resume - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - * Assumptions: - * We are within a critical section. - * - ****************************************************************************/ - -static void sched_note_switch(FAR struct tcb_s *tcb, uint8_t type) -{ - struct note_switch_s note; - - /* Format the note */ - - note.nsw_cmn.nc_length = sizeof(struct note_switch_s); - note.nsw_cmn.nc_type = type; - note.nsw_cmn.nc_priority = tcb->sched_priority; -#ifdef CONFIG_SMP - note.nsw_cmn.nc_cpu = tcb->cpu; -#endif - note.nsw_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff); - note.nsw_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff); - - note_systime((FAR struct note_common_s *)¬e); - - /* Add the note to circular buffer */ - - note_add((FAR const uint8_t *)¬e, sizeof(struct note_switch_s)); -} - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -388,12 +349,47 @@ void sched_note_stop(FAR struct tcb_s *tcb) void sched_note_suspend(FAR struct tcb_s *tcb) { - sched_note_switch(tcb, NOTE_SUSPEND); + struct note_suspend_s note; + + /* Format the note */ + + note.nsu_cmn.nc_length = sizeof(struct note_suspend_s); + note.nsu_cmn.nc_type = NOTE_SUSPEND; + note.nsu_cmn.nc_priority = tcb->sched_priority; +#ifdef CONFIG_SMP + note.nsu_cmn.nc_cpu = tcb->cpu; +#endif + note.nsu_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff); + note.nsu_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff); + note.nsu_state = tcb->task_state; + + note_systime((FAR struct note_common_s *)¬e); + + /* Add the note to circular buffer */ + + note_add((FAR const uint8_t *)¬e, sizeof(struct note_suspend_s)); } void sched_note_resume(FAR struct tcb_s *tcb) { - sched_note_switch(tcb, NOTE_RESUME); + struct note_resume_s note; + + /* Format the note */ + + note.nre_cmn.nc_length = sizeof(struct note_resume_s); + note.nre_cmn.nc_type = NOTE_RESUME; + note.nre_cmn.nc_priority = tcb->sched_priority; +#ifdef CONFIG_SMP + note.nre_cmn.nc_cpu = tcb->cpu; +#endif + note.nre_cmn.nc_pid[0] = (uint8_t)(tcb->pid & 0xff); + note.nre_cmn.nc_pid[1] = (uint8_t)((tcb->pid >> 8) & 0xff); + + note_systime((FAR struct note_common_s *)¬e); + + /* Add the note to circular buffer */ + + note_add((FAR const uint8_t *)¬e, sizeof(struct note_resume_s)); } #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION