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


The following commit(s) were added to refs/heads/master by this push:
     new e01d6b26cc sched/group: There is no need to use sched_[un]lock
e01d6b26cc is described below

commit e01d6b26cce12ce2e352192eda2709e80eb6a1f0
Author: hujun5 <[email protected]>
AuthorDate: Mon Dec 11 11:25:47 2023 +0800

    sched/group: There is no need to use sched_[un]lock
    
    Signed-off-by: hujun5 <[email protected]>
---
 sched/group/group_continue.c        |  9 +++------
 sched/group/group_killchildren.c    | 21 +++------------------
 sched/group/group_suspendchildren.c |  9 +++------
 3 files changed, 9 insertions(+), 30 deletions(-)

diff --git a/sched/group/group_continue.c b/sched/group/group_continue.c
index 1d7be075a9..0c6c6a3624 100644
--- a/sched/group/group_continue.c
+++ b/sched/group/group_continue.c
@@ -108,15 +108,12 @@ static int group_continue_handler(pid_t pid, FAR void 
*arg)
 
 int group_continue(FAR struct tcb_s *tcb)
 {
+  irqstate_t flags;
   int ret;
 
-  /* Lock the scheduler so that there this thread will not lose priority
-   * until all of its children are suspended.
-   */
-
-  sched_lock();
+  flags = enter_critical_section();
   ret = group_foreachchild(tcb->group, group_continue_handler, NULL);
-  sched_unlock();
+  leave_critical_section(flags);
   return ret;
 }
 
diff --git a/sched/group/group_killchildren.c b/sched/group/group_killchildren.c
index 9ae2295c1a..d0085a6f74 100644
--- a/sched/group/group_killchildren.c
+++ b/sched/group/group_killchildren.c
@@ -154,6 +154,7 @@ static int group_cancel_children_handler(pid_t pid, FAR 
void *arg)
 
 int group_kill_children(FAR struct tcb_s *tcb)
 {
+  irqstate_t flags;
   int ret;
 
   DEBUGASSERT(tcb->group);
@@ -163,19 +164,7 @@ int group_kill_children(FAR struct tcb_s *tcb)
       return 0;
     }
 
-#ifdef CONFIG_SMP
-  /* NOTE: sched_lock() is not enough for SMP
-   * because tcb->group will be accessed from the child tasks
-   */
-
-  irqstate_t flags = enter_critical_section();
-#else
-  /* Lock the scheduler so that there this thread will not lose priority
-   * until all of its children are suspended.
-   */
-
-  sched_lock();
-#endif
+  flags = enter_critical_section();
 
   /* Tell the children that this group has started exiting */
 
@@ -218,12 +207,8 @@ int group_kill_children(FAR struct tcb_s *tcb)
 
   ret = group_foreachchild(tcb->group, group_cancel_children_handler,
                            (FAR void *)((uintptr_t)tcb->pid));
-
-#ifdef CONFIG_SMP
   leave_critical_section(flags);
-#else
-  sched_unlock();
-#endif
+
   return ret;
 }
 
diff --git a/sched/group/group_suspendchildren.c 
b/sched/group/group_suspendchildren.c
index 06d9d58453..dc861be52f 100644
--- a/sched/group/group_suspendchildren.c
+++ b/sched/group/group_suspendchildren.c
@@ -101,16 +101,13 @@ static int group_suspend_children_handler(pid_t pid, FAR 
void *arg)
 
 int group_suspend_children(FAR struct tcb_s *tcb)
 {
+  irqstate_t flags;
   int ret;
 
-  /* Lock the scheduler so that there this thread will not lose priority
-   * until all of its children are suspended.
-   */
-
-  sched_lock();
+  flags = enter_critical_section();
   ret = group_foreachchild(tcb->group, group_suspend_children_handler,
                            (FAR void *)((uintptr_t)tcb->pid));
-  sched_unlock();
+  leave_critical_section(flags);
   return ret;
 }
 

Reply via email to