diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c index c94b8edaa57..412814d3398 100644 --- a/sched/pthread/pthread_condwait.c +++ b/sched/pthread/pthread_condwait.c @@ -94,6 +94,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex) sinfo("Give up mutex / take cond\n"); flags = enter_critical_section(); + sched_lock(); mutex->pid = INVALID_PROCESS_ID; #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE mflags = mutex->flags; @@ -116,6 +117,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex) ret = status; } + sched_unlock(); leave_critical_section(flags); /* Reacquire the mutex.