Clean up the nxmutex library

- Remove the redundant holder, as nxsem now manages hoder TID
- Remove DEBUGASSERTIONS which are managed in nxsem
- Remove the "reset" handling logic, as it is now managed in nxsem
- Inline the simplest functions

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This commit is contained in:
Jukka Laitinen
2025-04-23 19:23:22 +03:00
committed by Xiang Xiao
parent ffb49a25fb
commit 156469f158
5 changed files with 501 additions and 918 deletions
+487 -365
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -350,8 +350,7 @@ typedef struct pthread_mutex_s pthread_mutex_t;
#define PTHREAD_NXMUTEX_INITIALIZER { \
NXSEM_INITIALIZER(NXSEM_NO_MHOLDER, \
SEM_TYPE_MUTEX | PTHREAD_MUTEX_DEFAULT_PRIO_FLAGS), \
NXMUTEX_NO_HOLDER}
SEM_TYPE_MUTEX | PTHREAD_MUTEX_DEFAULT_PRIO_FLAGS)}
#define PTHREAD_NXRMUTEX_INITIALIZER {PTHREAD_NXMUTEX_INITIALIZER, 0}
#if defined(CONFIG_PTHREAD_MUTEX_TYPES) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -100,8 +100,8 @@ static void collect_deadlock(FAR struct tcb_s *tcb, FAR void *arg)
pid_t holder;
size_t i;
holder = mutex->holder;
if (holder == NXMUTEX_NO_HOLDER)
holder = nxmutex_get_holder(mutex);
if (holder < 0)
{
break;
}
+1 -1
View File
@@ -101,7 +101,7 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state,
if (tcb->task_state == TSTATE_WAIT_SEM &&
((FAR sem_t *)(tcb->waitobj))->flags & SEM_TYPE_MUTEX)
{
pid_t holder = ((FAR mutex_t *)(tcb->waitobj))->holder;
pid_t holder = nxmutex_get_holder((FAR mutex_t *)tcb->waitobj);
leave_critical_section(flags);
snprintf(state, length, "Waiting,Mutex:%d", holder);