1
0
Fork 0
forked from nuttx/nuttx-update

sched/group: There is no need to use sched_[un]lock

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2023-12-11 11:25:47 +08:00 committed by Xiang Xiao
parent c74206a982
commit e01d6b26cc
3 changed files with 9 additions and 30 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}