Skip to content

Commit

Permalink
pthread_mutx: remove unused critical_secton lock
Browse files Browse the repository at this point in the history
Caused the 'nlocks' are remove from mutex, so
here don't need do critical_secton lock like nxmutex_lock

Signed-off-by: ligd <[email protected]>
  • Loading branch information
GUIDINGLI authored and xiaoxiang781216 committed Sep 15, 2024
1 parent f07a186 commit fc50e57
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 17 deletions.
9 changes: 0 additions & 9 deletions sched/pthread/pthread_mutextimedlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions sched/pthread/pthread_mutexunlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -171,7 +164,6 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
}
}

leave_critical_section(flags);
sinfo("Returning %d\n", ret);
return ret;
}

0 comments on commit fc50e57

Please sign in to comment.