sched: Move the call of pthread_mutex_inconsistent to nxtask_recover

to avoid it spread around all possible exit path

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-05-25 13:17:34 +08:00 committed by Petro Karashchenko
parent d05b031d8d
commit 3b136771ff
4 changed files with 7 additions and 19 deletions

View File

@ -99,12 +99,6 @@ int pthread_cancel(pthread_t thread)
pthread_completejoin((pid_t)thread, PTHREAD_CANCELED);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
/* Recover any mutexes still held by the canceled thread */
pthread_mutex_inconsistent(tcb);
#endif
/* Then let nxtask_terminate do the real work */
return nxtask_terminate((pid_t)thread, false);

View File

@ -90,12 +90,6 @@ void nx_pthread_exit(FAR void *exit_value)
exit(EXIT_FAILURE);
}
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
/* Recover any mutexes still held by the canceled thread */
pthread_mutex_inconsistent(tcb);
#endif
/* Perform common task termination logic. This will get called again later
* through logic kicked off by _exit(). However, we need to call it before
* calling _exit() in order certain operations if this is the last thread

View File

@ -34,7 +34,6 @@
#include "task/task.h"
#include "group/group.h"
#include "sched/sched.h"
#include "pthread/pthread.h"
/****************************************************************************
* Public Functions
@ -68,12 +67,6 @@ void _exit(int status)
group_kill_children(tcb);
#endif
#if !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
/* Recover any mutexes still held by the canceled thread */
pthread_mutex_inconsistent(tcb);
#endif
/* Perform common task termination logic. This will get called again later
* through logic kicked off by up_exit(). However, we need to call it here
* so that we can flush buffered I/O (both of which may required

View File

@ -33,6 +33,7 @@
#include "semaphore/semaphore.h"
#include "wdog/wdog.h"
#include "mqueue/mqueue.h"
#include "pthread/pthread.h"
#include "sched/sched.h"
#include "task/task.h"
@ -61,6 +62,12 @@
void nxtask_recover(FAR struct tcb_s *tcb)
{
#if !defined(CONFIG_DISABLE_PTHREAD) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
/* Recover any mutexes still held by the canceled thread */
pthread_mutex_inconsistent(tcb);
#endif
/* The task is being deleted. Cancel in pending timeout events. */
wd_recover(tcb);