diff options
Diffstat (limited to 'nuttx/sched/sem_post.c')
-rw-r--r-- | nuttx/sched/sem_post.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/nuttx/sched/sem_post.c b/nuttx/sched/sem_post.c index b3780db1f..1c694b68c 100644 --- a/nuttx/sched/sem_post.c +++ b/nuttx/sched/sem_post.c @@ -123,17 +123,21 @@ int sem_post(FAR sem_t *sem) sem_releaseholder(sem); sem->semcount++; - /* If the result of of semaphore unlock is non-positive, then - * there must be some task waiting for the semaphore. - */ - #ifdef CONFIG_PRIORITY_INHERITANCE - /* Don't let it run until we complete the priority restoration - * steps. + /* Don't let any unblocked tasks run until we complete any priority + * restoration steps. Interrupts are disabled, but we do not want + * the head of the read-to-run list to be modified yet. + * + * NOTE: If this sched_lock is called from an interrupt handler, it + * will do nothing. */ sched_lock(); #endif + /* If the result of of semaphore unlock is non-positive, then + * there must be some task waiting for the semaphore. + */ + if (sem->semcount <= 0) { /* Check if there are any tasks in the waiting for semaphore |