From 2bfa0219131636df998fc00986a2c1ba6d3f29b6 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Mon, 11 Dec 2023 11:25:47 +0800 Subject: [PATCH] sched/group: There is no need to use sched_[un]lock Signed-off-by: hujun5 --- 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 1d7be075a9c7b..0c6c6a3624506 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 9ae2295c1acfa..d0085a6f741d1 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 06d9d584531b3..dc861be52fee6 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; }