sched/pthread: repalce sched_lock to enter_critical_section

After RR is enabled, an interrupt occurs during this period and the task cannot be switched

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2023-04-23 10:37:25 +08:00 committed by Xiang Xiao
parent 9162800255
commit a40a802f9b
1 changed files with 3 additions and 2 deletions

View File

@ -80,6 +80,7 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex,
{
pid_t mypid = nxsched_gettid();
int ret = EINVAL;
irqstate_t flags;
sinfo("mutex=%p\n", mutex);
DEBUGASSERT(mutex != NULL);
@ -90,7 +91,7 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex,
* checks. This all needs to be one atomic action.
*/
sched_lock();
flags = enter_critical_section();
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
/* All mutex types except for NORMAL (and DEFAULT) will return
@ -202,7 +203,7 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex,
}
}
sched_unlock();
leave_critical_section(flags);
}
sinfo("Returning %d\n", ret);