diff --git a/sched/sched/sched_getaffinity.c b/sched/sched/sched_getaffinity.c index b94f997eb2da0..1226e25a9195e 100644 --- a/sched/sched/sched_getaffinity.c +++ b/sched/sched/sched_getaffinity.c @@ -75,7 +75,6 @@ int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) /* Verify that the PID corresponds to a real task */ - sched_lock(); if (pid == 0) { tcb = this_task(); @@ -97,7 +96,6 @@ int nxsched_get_affinity(pid_t pid, size_t cpusetsize, FAR cpu_set_t *mask) ret = OK; } - sched_unlock(); return ret; } diff --git a/sched/sched/sched_getparam.c b/sched/sched/sched_getparam.c index fd196be53b2ed..6fd58306b4794 100644 --- a/sched/sched/sched_getparam.c +++ b/sched/sched/sched_getparam.c @@ -93,7 +93,6 @@ int nxsched_get_param(pid_t pid, FAR struct sched_param *param) { /* Get the TCB associated with this PID */ - sched_lock(); tcb = nxsched_get_tcb(pid); if (!tcb) { @@ -136,8 +135,6 @@ int nxsched_get_param(pid_t pid, FAR struct sched_param *param) } #endif } - - sched_unlock(); } return ret; diff --git a/sched/sched/sched_setparam.c b/sched/sched/sched_setparam.c index 8259d61e5e212..b8649799935a0 100644 --- a/sched/sched/sched_setparam.c +++ b/sched/sched/sched_setparam.c @@ -78,7 +78,6 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) { FAR struct tcb_s *rtcb; FAR struct tcb_s *tcb; - int ret; /* Verify that the requested priority is in the valid range */ @@ -87,12 +86,6 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) return -EINVAL; } - /* Prohibit modifications to the head of the ready-to-run task - * list while adjusting the priority - */ - - sched_lock(); - /* Check if the task to reprioritize is the calling task */ rtcb = this_task(); @@ -110,8 +103,7 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) { /* No task with this PID was found */ - ret = -ESRCH; - goto errout_with_lock; + return -ESRCH; } } @@ -128,8 +120,7 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) if (param->sched_ss_max_repl < 1 || param->sched_ss_max_repl > CONFIG_SCHED_SPORADIC_MAXREPL) { - ret = -EINVAL; - goto errout_with_lock; + return -EINVAL; } /* Convert timespec values to system clock ticks */ @@ -163,8 +154,7 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) if (repl_ticks < budget_ticks) #endif { - ret = -EINVAL; - goto errout_with_lock; + return -EINVAL; } /* Stop/reset current sporadic scheduling */ @@ -198,18 +188,14 @@ int nxsched_set_param(pid_t pid, FAR const struct sched_param *param) leave_critical_section(flags); if (ret < 0) { - goto errout_with_lock; + return ret; } } #endif /* Then perform the reprioritization */ - ret = nxsched_reprioritize(tcb, param->sched_priority); - -errout_with_lock: - sched_unlock(); - return ret; + return nxsched_reprioritize(tcb, param->sched_priority); } /**************************************************************************** diff --git a/sched/sched/sched_setscheduler.c b/sched/sched/sched_setscheduler.c index b20433dcca91c..4c6ed2a274183 100644 --- a/sched/sched/sched_setscheduler.c +++ b/sched/sched/sched_setscheduler.c @@ -80,7 +80,6 @@ int nxsched_set_scheduler(pid_t pid, int policy, { FAR struct tcb_s *tcb; irqstate_t flags; - int ret; /* Check for supported scheduling policy */ @@ -120,12 +119,6 @@ int nxsched_set_scheduler(pid_t pid, int policy, return -ESRCH; } - /* Prohibit any context switches while we muck with priority and scheduler - * settings. - */ - - sched_lock(); - /* Further, disable timer interrupts while we set up scheduling policy. */ flags = enter_critical_section(); @@ -270,14 +263,11 @@ int nxsched_set_scheduler(pid_t pid, int policy, /* Set the new priority */ - ret = nxsched_reprioritize(tcb, param->sched_priority); - sched_unlock(); - return ret; + return nxsched_reprioritize(tcb, param->sched_priority); #ifdef CONFIG_SCHED_SPORADIC errout_with_irq: leave_critical_section(flags); - sched_unlock(); return ret; #endif } diff --git a/sched/sched/sched_waitid.c b/sched/sched/sched_waitid.c index 0dcbb087fe0ff..22188f5755626 100644 --- a/sched/sched/sched_waitid.c +++ b/sched/sched/sched_waitid.c @@ -152,6 +152,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) FAR struct child_status_s *child; bool retains; #endif + irqstate_t flags; sigset_t set; int errcode; int ret; @@ -198,18 +199,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) sigemptyset(&set); nxsig_addset(&set, SIGCHLD); - - /* NOTE: sched_lock() is not enough for SMP - * because the child task is running on another CPU - */ - -#ifdef CONFIG_SMP - irqstate_t flags = enter_critical_section(); -#else - /* Disable pre-emption so that nothing changes while the loop executes */ - - sched_lock(); -#endif + flags = enter_critical_section(); /* Verify that this task actually has children and that the requested * TCB is actually a child of this task. @@ -464,20 +454,12 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options) } } -#ifdef CONFIG_SMP leave_critical_section(flags); -#else - sched_unlock(); -#endif leave_cancellation_point(); return OK; errout: -#ifdef CONFIG_SMP leave_critical_section(flags); -#else - sched_unlock(); -#endif leave_cancellation_point(); set_errno(errcode); return ERROR; diff --git a/sched/sched/sched_waitpid.c b/sched/sched/sched_waitpid.c index 078a35a7bafc7..ff77a83e44c66 100644 --- a/sched/sched/sched_waitpid.c +++ b/sched/sched/sched_waitpid.c @@ -101,13 +101,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options) * because the child task is running on another CPU */ -#ifdef CONFIG_SMP irqstate_t flags = enter_critical_section(); -#else - /* Disable pre-emption so that nothing changes in the following tests */ - - sched_lock(); -#endif /* Get the TCB corresponding to this PID */ @@ -198,12 +192,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options) ret = pid; errout: -#ifdef CONFIG_SMP leave_critical_section(flags); -#else - sched_unlock(); -#endif - return ret; } @@ -230,6 +219,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options) bool retains; #endif FAR struct siginfo info; + irqstate_t flags; sigset_t set; int ret; @@ -237,18 +227,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options) sigemptyset(&set); nxsig_addset(&set, SIGCHLD); - - /* NOTE: sched_lock() is not enough for SMP - * because the child task is running on another CPU - */ - -#ifdef CONFIG_SMP - irqstate_t flags = enter_critical_section(); -#else - /* Disable pre-emption so that nothing changes while the loop executes */ - - sched_lock(); -#endif + flags = enter_critical_section(); /* Verify that this task actually has children and that the requested PID * is actually a child of this task. @@ -495,12 +474,7 @@ pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options) ret = pid; errout: -#ifdef CONFIG_SMP leave_critical_section(flags); -#else - sched_unlock(); -#endif - return ret; } #endif /* CONFIG_SCHED_HAVE_PARENT */