pthread: sched_lock should replace with enter_critical_secion

sched_lock cannot lock threads from other CPUs, use enter_critical_section

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2023-05-06 23:12:20 +08:00
committed by Xiang Xiao
parent 447a0bce95
commit 9cd8ff5a0b
+3 -2
View File
@@ -101,6 +101,7 @@ static inline bool pthread_mutex_islocked(FAR struct pthread_mutex_s *mutex)
int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
{
int ret = EPERM;
irqstate_t flags;
sinfo("mutex=%p\n", mutex);
DEBUGASSERT(mutex != NULL);
@@ -113,7 +114,7 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
* This all needs to be one atomic action.
*/
sched_lock();
flags = enter_critical_section();
/* The unlock operation is only performed if the mutex is actually locked.
* EPERM *must* be returned if the mutex type is PTHREAD_MUTEX_ERRORCHECK
@@ -223,7 +224,7 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
}
}
sched_unlock();
leave_critical_section(flags);
sinfo("Returning %d\n", ret);
return ret;
}