From fc50e57a26090a7b0df8e3e9249b0792aec02f1a Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 13 Sep 2024 14:59:47 +0800 Subject: [PATCH] pthread_mutx: remove unused critical_secton lock Caused the 'nlocks' are remove from mutex, so here don't need do critical_secton lock like nxmutex_lock Signed-off-by: ligd --- sched/pthread/pthread_mutextimedlock.c | 9 --------- sched/pthread/pthread_mutexunlock.c | 8 -------- 2 files changed, 17 deletions(-) diff --git a/sched/pthread/pthread_mutextimedlock.c b/sched/pthread/pthread_mutextimedlock.c index 997c51a592..6395ed6a7c 100644 --- a/sched/pthread/pthread_mutextimedlock.c +++ b/sched/pthread/pthread_mutextimedlock.c @@ -81,7 +81,6 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex, FAR const struct timespec *abs_timeout) { int ret = EINVAL; - irqstate_t flags; sinfo("mutex=%p\n", mutex); DEBUGASSERT(mutex != NULL); @@ -92,12 +91,6 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex, pid_t pid = mutex_get_holder(&mutex->mutex); #endif - /* Make sure the semaphore is stable while we make the following - * checks. This all needs to be one atomic action. - */ - - flags = enter_critical_section(); - #ifdef CONFIG_PTHREAD_MUTEX_TYPES /* All mutex types except for NORMAL (and DEFAULT) will return * an error if the caller does not hold the mutex. @@ -188,8 +181,6 @@ int pthread_mutex_timedlock(FAR pthread_mutex_t *mutex, ret = pthread_mutex_take(mutex, abs_timeout); } - - leave_critical_section(flags); } sinfo("Returning %d\n", ret); diff --git a/sched/pthread/pthread_mutexunlock.c b/sched/pthread/pthread_mutexunlock.c index f21c233701..2e73b77cb2 100644 --- a/sched/pthread/pthread_mutexunlock.c +++ b/sched/pthread/pthread_mutexunlock.c @@ -70,7 +70,6 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex) { int ret = EPERM; - irqstate_t flags; sinfo("mutex=%p\n", mutex); DEBUGASSERT(mutex != NULL); @@ -79,12 +78,6 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex) return EINVAL; } - /* Make sure the semaphore is stable while we make the following checks. - * This all needs to be one atomic action. - */ - - 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 * or PTHREAD_MUTEX_RECURSIVE, or the mutex is a robust mutex, and the @@ -171,7 +164,6 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex) } } - leave_critical_section(flags); sinfo("Returning %d\n", ret); return ret; }