sched: we use spin_lock_irqsave replace enter_critical_section to protect g_irqvector

enter_critical_section may be called before os initialized

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2024-01-11 11:27:31 +08:00 committed by Xiang Xiao
parent 5cee996588
commit 2ee8aa6f2b
2 changed files with 4 additions and 4 deletions

View file

@ -72,7 +72,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
* to the unexpected interrupt handler.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(NULL);
if (isr == NULL)
{
/* Disable the interrupt if we can before detaching it. We might
@ -121,7 +121,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
g_irqvector[ndx].count = 0;
#endif
leave_critical_section(flags);
spin_unlock_irqrestore(NULL, flags);
ret = OK;
}

View file

@ -218,7 +218,7 @@ int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
ndx = irq;
#endif
flags = enter_critical_section();
flags = spin_lock_irqsave(NULL);
if (g_irqvector[ndx].handler == irqchain_dispatch)
{
@ -264,7 +264,7 @@ int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
ret = irq_detach(irq);
}
leave_critical_section(flags);
spin_unlock_irqrestore(NULL, flags);
}
return ret;