sched/pthread: There is no need to use sched_[un]lock

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2024-10-11 14:49:59 +08:00 committed by archer
parent b503b323ce
commit 794d362335
5 changed files with 0 additions and 38 deletions

View File

@ -442,8 +442,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
#endif
}
sched_lock();
/* Return the thread information to the caller */
if (thread != NULL)
@ -455,8 +453,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
nxtask_activate((FAR struct tcb_s *)ptcb);
sched_unlock();
return OK;
errout_with_tcb:

View File

@ -150,10 +150,6 @@ int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
DEBUGASSERT(mutex != NULL);
if (mutex != NULL)
{
/* Make sure that no unexpected context switches occur */
sched_lock();
/* Error out if the mutex is already in an inconsistent state. */
if ((mutex->flags & _PTHREAD_MFLAGS_INCONSISTENT) != 0)
@ -201,8 +197,6 @@ int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
}
}
}
sched_unlock();
}
return ret;
@ -234,10 +228,6 @@ int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex)
DEBUGASSERT(mutex != NULL);
if (mutex != NULL)
{
/* Make sure that no unexpected context switches occur */
sched_lock();
/* Error out if the mutex is already in an inconsistent state. */
if ((mutex->flags & _PTHREAD_MFLAGS_INCONSISTENT) != 0)
@ -269,8 +259,6 @@ int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex)
pthread_mutex_add(mutex);
}
}
sched_unlock();
}
return ret;

View File

@ -84,10 +84,6 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex)
{
pid_t pid;
/* Make sure the mutex is stable while we make the following checks. */
sched_lock();
pid = mutex_get_holder(&mutex->mutex);
/* Is the mutex available? */
@ -133,8 +129,6 @@ int pthread_mutex_consistent(FAR pthread_mutex_t *mutex)
mutex->flags &= _PTHREAD_MFLAGS_ROBUST;
ret = OK;
}
sched_unlock();
}
sinfo("Returning %d\n", ret);

View File

@ -69,12 +69,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
{
pid_t pid;
/* Make sure the semaphore is stable while we make the following
* checks.
*/
sched_lock();
pid = mutex_get_holder(&mutex->mutex);
/* Is the mutex available? */
@ -141,8 +135,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
status = mutex_destroy(&mutex->mutex);
ret = ((status < 0) ? -status : OK);
}
sched_unlock();
}
sinfo("Returning %d\n", ret);

View File

@ -82,12 +82,6 @@ int pthread_mutex_trylock(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.
*/
sched_lock();
/* Try to get the semaphore. */
status = pthread_mutex_trytake(mutex);
@ -163,8 +157,6 @@ int pthread_mutex_trylock(FAR pthread_mutex_t *mutex)
{
ret = status;
}
sched_unlock();
}
sinfo("Returning %d\n", ret);