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

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


The following commit(s) were added to refs/heads/master by this push:
     new a46eb84334 sched: Use spinlock repalce sched_[un]lock in some place
a46eb84334 is described below

commit a46eb84334d0d87bdb4e0d2e10f7475e151786e1
Author: hujun5 <huj...@xiaomi.com>
AuthorDate: Wed Oct 16 09:35:15 2024 +0800

    sched: Use spinlock repalce sched_[un]lock in some place
    
    Signed-off-by: hujun5 <huj...@xiaomi.com>
---
 sched/signal/sig_findaction.c | 5 +++--
 sched/task/task_setup.c       | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/sched/signal/sig_findaction.c b/sched/signal/sig_findaction.c
index 42176fdc65..42fa092ed8 100644
--- a/sched/signal/sig_findaction.c
+++ b/sched/signal/sig_findaction.c
@@ -44,6 +44,7 @@
 FAR sigactq_t *nxsig_find_action(FAR struct task_group_s *group, int signo)
 {
   FAR sigactq_t *sigact = NULL;
+  irqstate_t flags;
 
   /* Verify the caller's sanity */
 
@@ -54,7 +55,7 @@ FAR sigactq_t *nxsig_find_action(FAR struct task_group_s 
*group, int signo)
        * protection.
        */
 
-      sched_lock();
+      flags = spin_lock_irqsave(NULL);
 
       /* Search the list for a sigaction on this signal */
 
@@ -62,7 +63,7 @@ FAR sigactq_t *nxsig_find_action(FAR struct task_group_s 
*group, int signo)
            ((sigact) && (sigact->signo != signo));
            sigact = sigact->flink);
 
-      sched_unlock();
+      spin_unlock_irqrestore(NULL, flags);
     }
 
   return sigact;
diff --git a/sched/task/task_setup.c b/sched/task/task_setup.c
index fc4a38d41f..123af650f4 100644
--- a/sched/task/task_setup.c
+++ b/sched/task/task_setup.c
@@ -404,6 +404,7 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, 
int priority,
                                     uint8_t ttype)
 {
   FAR struct tcb_s *rtcb = this_task();
+  irqstate_t flags;
   int ret;
 
   /* Assign a unique task ID to the task. */
@@ -481,10 +482,10 @@ static int nxthread_setup_scheduler(FAR struct tcb_s 
*tcb, int priority,
 
       /* Add the task to the inactive task list */
 
-      sched_lock();
+      flags = spin_lock_irqsave(NULL);
       dq_addfirst((FAR dq_entry_t *)tcb, list_inactivetasks());
       tcb->task_state = TSTATE_TASK_INACTIVE;
-      sched_unlock();
+      spin_unlock_irqrestore(NULL, flags);
     }
 
   return ret;

Reply via email to