Skip to content

Commit

Permalink
sched/pthread: repalce sched_lcok to enter_critical_section
Browse files Browse the repository at this point in the history
After RR is enabled, an interrupt occurs during this period and the task cannot be switched

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
  • Loading branch information
Gary-Hobson committed Apr 11, 2023
1 parent 743d13c commit ac629dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sched/pthread/pthread_mutextimedlock.c
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -202,7 +203,7 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex,
}
}

sched_unlock();
leave_critical_section(flags);
}

sinfo("Returning %d\n", ret);
Expand Down

0 comments on commit ac629dd

Please sign in to comment.