diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index caec63431e..f9d00b0a47 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -108,7 +108,8 @@ #define TCB_FLAG_SYSCALL (1 << 10) /* Bit 9: In a system call */ #define TCB_FLAG_EXIT_PROCESSING (1 << 11) /* Bit 10: Exitting */ #define TCB_FLAG_FREE_STACK (1 << 12) /* Bit 12: Free stack after exit */ - /* Bits 13-15: Available */ +#define TCB_FLAG_MEM_CHECK (1 << 13) /* Bit 13: Memory check */ + /* Bits 14-15: Available */ /* Values for struct task_group tg_flags */ diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index ab984a057c..96486b12cd 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -184,6 +185,14 @@ void irq_dispatch(int irq, FAR void *context) sched_note_irqhandler(irq, vector, false); #endif +#ifdef CONFIG_DEBUG_MM + if ((g_running_tasks[this_cpu()]->flags & TCB_FLAG_MEM_CHECK) || \ + (this_task()->flags & TCB_FLAG_MEM_CHECK)) + { + kmm_checkcorruption(); + } +#endif + /* Record the new "running" task. g_running_tasks[] is only used by * assertion logic for reporting crashes. */