Skip to content

Commit

Permalink
sched/group: There is no need to use sched_[un]lock
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed Oct 9, 2024
1 parent 846cb7d commit 2bfa021
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
9 changes: 3 additions & 6 deletions sched/group/group_continue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
21 changes: 3 additions & 18 deletions sched/group/group_killchildren.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */

Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 3 additions & 6 deletions sched/group/group_suspendchildren.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2bfa021

Please sign in to comment.