mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
pthread: remove tl_lock
This lock is currently used in three places, mainly to protect tls->tl_mhead. Among them, pthread_mutex_add and pthread_mutex_remove involve writing to tls->tl_mhead, and there is certainly no conflict within the same thread. As for pthread_mutex_inconsistent, it involves reading. Currently, it can only be called when the TCB task corresponding to this tls exits, and the TCB corresponding to the tls can no longer continue to run. It seems that adding the lock serves no real purpose. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
f4c23eb88b
commit
082a3d3085
6 changed files with 0 additions and 24 deletions
|
|
@ -232,9 +232,6 @@ struct tls_info_s
|
|||
#if !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
|
||||
FAR struct pthread_mutex_s *tl_mhead; /* List of mutexes held by thread */
|
||||
#endif
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
mutex_t tl_lock;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -66,10 +66,8 @@ static void pthread_mutex_add(FAR struct pthread_mutex_s *mutex)
|
|||
|
||||
/* Add the mutex to the list of mutexes held by this pthread */
|
||||
|
||||
nxmutex_lock(&tls->tl_lock);
|
||||
mutex->flink = tls->tl_mhead;
|
||||
tls->tl_mhead = mutex;
|
||||
nxmutex_unlock(&tls->tl_lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -92,8 +90,6 @@ static void pthread_mutex_remove(FAR struct pthread_mutex_s *mutex)
|
|||
FAR struct pthread_mutex_s *curr;
|
||||
FAR struct pthread_mutex_s *prev;
|
||||
|
||||
nxmutex_lock(&tls->tl_lock);
|
||||
|
||||
/* Remove the mutex from the list of mutexes held by this task */
|
||||
|
||||
for (prev = NULL, curr = tls->tl_mhead;
|
||||
|
|
@ -118,7 +114,6 @@ static void pthread_mutex_remove(FAR struct pthread_mutex_s *mutex)
|
|||
}
|
||||
|
||||
mutex->flink = NULL;
|
||||
nxmutex_unlock(&tls->tl_lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -64,8 +64,6 @@ void pthread_mutex_inconsistent(FAR struct tls_info_s *tls)
|
|||
{
|
||||
FAR struct pthread_mutex_s *mutex;
|
||||
|
||||
nxmutex_lock(&tls->tl_lock);
|
||||
|
||||
/* Remove and process each mutex held by this task */
|
||||
|
||||
while (tls->tl_mhead != NULL)
|
||||
|
|
@ -81,6 +79,4 @@ void pthread_mutex_inconsistent(FAR struct tls_info_s *tls)
|
|||
mutex->flags |= _PTHREAD_MFLAGS_INCONSISTENT;
|
||||
mutex_reset(&mutex->mutex);
|
||||
}
|
||||
|
||||
nxmutex_unlock(&tls->tl_lock);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,6 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t ttype)
|
|||
timer_deleteall(tcb->pid);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
nxmutex_destroy(&nxsched_get_tls(tcb)->tl_lock);
|
||||
#endif
|
||||
|
||||
/* Release the task's process ID if one was assigned. PID
|
||||
* zero is reserved for the IDLE task. The TCB of the IDLE
|
||||
* task is never release so a value of zero simply means that
|
||||
|
|
|
|||
|
|
@ -81,9 +81,5 @@ int tls_dup_info(FAR struct tcb_s *dst, FAR struct tcb_s *src)
|
|||
|
||||
info->tl_tid = dst->pid;
|
||||
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
nxmutex_init(&info->tl_lock);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,9 +84,5 @@ int tls_init_info(FAR struct tcb_s *tcb)
|
|||
|
||||
info->tl_argv = NULL;
|
||||
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
nxmutex_init(&info->tl_lock);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue