This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 2ee8aa6f2b4ae5384f7dc984f467702d5f3fbf40
Author: hujun5 <[email protected]>
AuthorDate: Thu Jan 11 11:27:31 2024 +0800

    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 <[email protected]>
---
 sched/irq/irq_attach.c | 4 ++--
 sched/irq/irq_chain.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sched/irq/irq_attach.c b/sched/irq/irq_attach.c
index 0ca62f0238..83249c4a2e 100644
--- a/sched/irq/irq_attach.c
+++ b/sched/irq/irq_attach.c
@@ -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;
     }
 
diff --git a/sched/irq/irq_chain.c b/sched/irq/irq_chain.c
index ba83b0befa..f5bd0736c9 100644
--- a/sched/irq/irq_chain.c
+++ b/sched/irq/irq_chain.c
@@ -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;

Reply via email to