diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index 7a6c8711f6..a2afbb48c5 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -39,6 +39,12 @@ * Pre-processor Definitions ****************************************************************************/ +#ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE +# define NUSER_IRQS CONFIG_ARCH_NUSER_INTERRUPTS +#else +# define NUSER_IRQS NR_IRQS +#endif + /* INCR_COUNT - Increment the count of interrupts taken on this IRQ number */ #ifndef CONFIG_SCHED_IRQMONITOR @@ -81,9 +87,13 @@ vector(irq, context, arg); \ elapsed = up_perf_gettime() - start; \ up_perf_convert(elapsed, &delta); \ - if (delta.tv_nsec > g_irqvector[ndx].time) \ + if (ndx < NUSER_IRQS) \ { \ - g_irqvector[ndx].time = delta.tv_nsec; \ + INCR_COUNT(ndx); \ + if (delta.tv_nsec > g_irqvector[ndx].time) \ + { \ + g_irqvector[ndx].time = delta.tv_nsec; \ + } \ } \ if (CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ > 0 && \ elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ) \ @@ -130,8 +140,6 @@ void irq_dispatch(int irq, FAR void *context) vector = g_irqvector[ndx].handler; arg = g_irqvector[ndx].arg; } - - INCR_COUNT(ndx); } #else if (g_irqvector[ndx].handler) @@ -139,8 +147,6 @@ void irq_dispatch(int irq, FAR void *context) vector = g_irqvector[ndx].handler; arg = g_irqvector[ndx].arg; } - - INCR_COUNT(ndx); #endif } #endif