This is an automated email from the ASF dual-hosted git repository.
ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 217e685bebc pthread: move pthread_cond to userspace
217e685bebc is described below
commit 217e685bebca4a399b20a6ec334a1b8cc5443148
Author: hujun5 <[email protected]>
AuthorDate: Thu Jun 19 15:19:35 2025 +0800
pthread: move pthread_cond to userspace
Move pthread condition variable implementation from kernel (sched/pthread)
to userspace library (libs/libc/pthread). This allows userspace to handle
condition variable operations directly, reducing syscall overhead and
improving performance for pthread applications.
Signed-off-by: hujun5 <[email protected]>
---
include/nuttx/pthread.h | 54 ------------
include/sys/syscall_lookup.h | 4 -
libs/libc/pthread/CMakeLists.txt | 6 +-
libs/libc/pthread/Make.defs | 5 +-
libs/libc/pthread/pthread.h | 99 ++++++++++++++++++++++
.../libc}/pthread/pthread_condbroadcast.c | 4 +-
.../libc}/pthread/pthread_condclockwait.c | 8 +-
{sched => libs/libc}/pthread/pthread_condsignal.c | 4 +-
{sched => libs/libc}/pthread/pthread_condwait.c | 4 +-
libs/libc/pthread/pthread_mutex.c | 2 +
libs/libc/pthread/pthread_mutex_consistent.c | 2 +
libs/libc/pthread/pthread_mutex_destroy.c | 2 +
.../libc/pthread/pthread_mutex_inconsistent.c | 11 +--
libs/libc/pthread/pthread_mutex_init.c | 2 +
libs/libc/pthread/pthread_mutex_timedlock.c | 2 +
libs/libc/pthread/pthread_mutex_trylock.c | 2 +
libs/libc/pthread/pthread_mutex_unlock.c | 2 +
libs/libc/semaphore/sem_wait.c | 72 ++++++++++++++++
sched/pthread/CMakeLists.txt | 8 --
sched/pthread/Make.defs | 7 +-
sched/pthread/pthread.h | 4 +-
sched/semaphore/sem_clockwait.c | 39 ---------
sched/semaphore/sem_wait.c | 32 -------
sched/task/task_recover.c | 2 +-
syscall/syscall.csv | 4 -
25 files changed, 209 insertions(+), 172 deletions(-)
diff --git a/include/nuttx/pthread.h b/include/nuttx/pthread.h
index 07f825c27a0..a2d7114e9fa 100644
--- a/include/nuttx/pthread.h
+++ b/include/nuttx/pthread.h
@@ -100,60 +100,6 @@
}
#endif
-#ifdef CONFIG_PTHREAD_MUTEX_TYPES
-# define mutex_init(m) nxrmutex_init(m)
-# define mutex_destroy(m) nxrmutex_destroy(m)
-# define mutex_is_hold(m) nxrmutex_is_hold(m)
-# define mutex_is_locked(m) nxrmutex_is_locked(m)
-# define mutex_is_recursive(m) nxrmutex_is_recursive(m)
-# define mutex_get_holder(m) nxrmutex_get_holder(m)
-# define mutex_reset(m) nxrmutex_reset(m)
-# define mutex_unlock(m) nxrmutex_unlock(m)
-# define mutex_lock(m) nxrmutex_lock(m)
-# define mutex_trylock(m) nxrmutex_trylock(m)
-# define mutex_breaklock(m,v) nxrmutex_breaklock(m,v)
-# define mutex_restorelock(m,v) nxrmutex_restorelock(m,v)
-# define mutex_clocklock(m,t) nxrmutex_clocklock(m,CLOCK_REALTIME,t)
-# define mutex_set_protocol(m,p) nxrmutex_set_protocol(m,p)
-# define mutex_getprioceiling(m,p) nxrmutex_getprioceiling(m,p)
-# define mutex_setprioceiling(m,p,o) nxrmutex_setprioceiling(m,p,o)
-#else
-# define mutex_init(m) nxmutex_init(m)
-# define mutex_destroy(m) nxmutex_destroy(m)
-# define mutex_is_hold(m) nxmutex_is_hold(m)
-# define mutex_is_recursive(m) (false)
-# define mutex_is_locked(m) nxmutex_is_locked(m)
-# define mutex_get_holder(m) nxmutex_get_holder(m)
-# define mutex_reset(m) nxmutex_reset(m)
-# define mutex_unlock(m) nxmutex_unlock(m)
-# define mutex_lock(m) nxmutex_lock(m)
-# define mutex_trylock(m) nxmutex_trylock(m)
-# define mutex_breaklock(m,v) nxmutex_breaklock(m, v)
-# define mutex_restorelock(m,v) nxmutex_restorelock(m, v)
-# define mutex_clocklock(m,t) nxmutex_clocklock(m,CLOCK_REALTIME,t)
-# define mutex_set_protocol(m,p) nxmutex_set_protocol(m,p)
-# define mutex_getprioceiling(m,p) nxmutex_getprioceiling(m,p)
-# define mutex_setprioceiling(m,p,o) nxmutex_setprioceiling(m,p,o)
-#endif
-
-#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
- FAR const struct timespec *abs_timeout);
-int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex);
-int pthread_mutex_give(FAR struct pthread_mutex_s *mutex);
-int pthread_mutex_breaklock(FAR struct pthread_mutex_s *mutex,
- FAR unsigned int *breakval);
-int pthread_mutex_restorelock(FAR struct pthread_mutex_s *mutex,
- unsigned int breakval);
-#else
-# define pthread_mutex_take(m,abs_timeout) -mutex_clocklock(&(m)->mutex, \
- abs_timeout)
-# define pthread_mutex_trytake(m) -mutex_trylock(&(m)->mutex)
-# define pthread_mutex_give(m) -mutex_unlock(&(m)->mutex)
-# define pthread_mutex_breaklock(m,v) -mutex_breaklock(&(m)->mutex,v)
-# define pthread_mutex_restorelock(m,v) -mutex_restorelock(&(m)->mutex,v)
-#endif
-
/****************************************************************************
* Public Types
****************************************************************************/
diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index 1e97947ef84..de562af0ccb 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -316,9 +316,6 @@ SYSCALL_LOOKUP(munmap, 2)
#ifndef CONFIG_DISABLE_PTHREAD
SYSCALL_LOOKUP(pthread_cancel, 1)
- SYSCALL_LOOKUP(pthread_cond_broadcast, 1)
- SYSCALL_LOOKUP(pthread_cond_signal, 1)
- SYSCALL_LOOKUP(pthread_cond_wait, 2)
SYSCALL_LOOKUP(nx_pthread_create, 5)
SYSCALL_LOOKUP(pthread_detach, 1)
SYSCALL_LOOKUP(nx_pthread_exit, 1)
@@ -330,7 +327,6 @@ SYSCALL_LOOKUP(munmap, 2)
SYSCALL_LOOKUP(pthread_setaffinity_np, 3)
SYSCALL_LOOKUP(pthread_getaffinity_np, 3)
#endif
- SYSCALL_LOOKUP(pthread_cond_clockwait, 4)
SYSCALL_LOOKUP(pthread_sigmask, 3)
#endif
diff --git a/libs/libc/pthread/CMakeLists.txt b/libs/libc/pthread/CMakeLists.txt
index 22700b4b28b..4032cdecf56 100644
--- a/libs/libc/pthread/CMakeLists.txt
+++ b/libs/libc/pthread/CMakeLists.txt
@@ -66,9 +66,13 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_condattr_setpshared.c
pthread_condattr_setclock.c
pthread_condattr_getclock.c
+ pthread_condbroadcast.c
+ pthread_condclockwait.c
pthread_condinit.c
pthread_conddestroy.c
pthread_condtimedwait.c
+ pthread_condsignal.c
+ pthread_condwait.c
pthread_create.c
pthread_equal.c
pthread_exit.c
@@ -117,7 +121,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_concurrency.c)
if(NOT CONFIG_PTHREAD_MUTEX_UNSAFE)
- list(APPEND SRCS pthread_mutex_consistent.c)
+ list(APPEND SRCS pthread_mutex_consistent.c pthread_mutex_inconsistent.c)
endif()
if(CONFIG_SMP)
diff --git a/libs/libc/pthread/Make.defs b/libs/libc/pthread/Make.defs
index 94261b4696c..b043230e23b 100644
--- a/libs/libc/pthread/Make.defs
+++ b/libs/libc/pthread/Make.defs
@@ -46,7 +46,8 @@ CSRCS += pthread_condattr_init.c pthread_condattr_destroy.c
CSRCS += pthread_condattr_getpshared.c pthread_condattr_setpshared.c
CSRCS += pthread_condattr_setclock.c pthread_condattr_getclock.c
CSRCS += pthread_condinit.c pthread_conddestroy.c pthread_condtimedwait.c
-CSRCS += pthread_create.c pthread_equal.c pthread_exit.c pthread_kill.c
+CSRCS += pthread_equal.c pthread_condbroadcast.c pthread_condclockwait.c
pthread_condsignal.c
+CSRCS += pthread_condwait.c pthread_create.c pthread_exit.c pthread_kill.c
CSRCS += pthread_setname_np.c pthread_getname_np.c
CSRCS += pthread_get_stackaddr_np.c pthread_get_stacksize_np.c
CSRCS += pthread_mutexattr_init.c pthread_mutexattr_destroy.c
@@ -73,7 +74,7 @@ CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c
endif
ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
-CSRCS += pthread_mutex_consistent.c
+CSRCS += pthread_mutex_consistent.c pthread_mutex_inconsistent.c
endif
ifeq ($(CONFIG_PTHREAD_SPINLOCKS),y)
diff --git a/libs/libc/pthread/pthread.h b/libs/libc/pthread/pthread.h
new file mode 100644
index 00000000000..3bfe693b86e
--- /dev/null
+++ b/libs/libc/pthread/pthread.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+ * libs/libc/pthread/pthread.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_LIBS_LIBC_PTHREAD_H
+#define __INCLUDE_LIBS_LIBC_PTHREAD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <pthread.h>
+#include <sched.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_PTHREAD_MUTEX_TYPES
+# define mutex_init(m) nxrmutex_init(m)
+# define mutex_destroy(m) nxrmutex_destroy(m)
+# define mutex_is_hold(m) nxrmutex_is_hold(m)
+# define mutex_is_locked(m) nxrmutex_is_locked(m)
+# define mutex_is_recursive(m) nxrmutex_is_recursive(m)
+# define mutex_get_holder(m) nxrmutex_get_holder(m)
+# define mutex_reset(m) nxrmutex_reset(m)
+# define mutex_unlock(m) nxrmutex_unlock(m)
+# define mutex_lock(m) nxrmutex_lock(m)
+# define mutex_trylock(m) nxrmutex_trylock(m)
+# define mutex_breaklock(m,v) nxrmutex_breaklock(m,v)
+# define mutex_restorelock(m,v) nxrmutex_restorelock(m,v)
+# define mutex_clocklock(m,t) nxrmutex_clocklock(m,CLOCK_REALTIME,t)
+# define mutex_set_protocol(m,p) nxrmutex_set_protocol(m,p)
+# define mutex_getprioceiling(m,p) nxrmutex_getprioceiling(m,p)
+# define mutex_setprioceiling(m,p,o) nxrmutex_setprioceiling(m,p,o)
+#else
+# define mutex_init(m) nxmutex_init(m)
+# define mutex_destroy(m) nxmutex_destroy(m)
+# define mutex_is_hold(m) nxmutex_is_hold(m)
+# define mutex_is_recursive(m) (false)
+# define mutex_is_locked(m) nxmutex_is_locked(m)
+# define mutex_get_holder(m) nxmutex_get_holder(m)
+# define mutex_reset(m) nxmutex_reset(m)
+# define mutex_unlock(m) nxmutex_unlock(m)
+# define mutex_lock(m) nxmutex_lock(m)
+# define mutex_trylock(m) nxmutex_trylock(m)
+# define mutex_breaklock(m,v) nxmutex_breaklock(m, v)
+# define mutex_restorelock(m,v) nxmutex_restorelock(m, v)
+# define mutex_clocklock(m,t) nxmutex_clocklock(m,CLOCK_REALTIME,t)
+# define mutex_set_protocol(m,p) nxmutex_set_protocol(m,p)
+# define mutex_getprioceiling(m,p) nxmutex_getprioceiling(m,p)
+# define mutex_setprioceiling(m,p,o) nxmutex_setprioceiling(m,p,o)
+#endif
+
+#define COND_WAIT_COUNT(cond) ((FAR atomic_t *)&(cond)->wait_count)
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
+int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
+ FAR const struct timespec *abs_timeout);
+int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex);
+int pthread_mutex_give(FAR struct pthread_mutex_s *mutex);
+int pthread_mutex_breaklock(FAR struct pthread_mutex_s *mutex,
+ FAR unsigned int *breakval);
+int pthread_mutex_restorelock(FAR struct pthread_mutex_s *mutex,
+ unsigned int breakval);
+#else
+# define pthread_mutex_take(m,abs_timeout) -mutex_clocklock(&(m)->mutex, \
+ abs_timeout)
+# define pthread_mutex_trytake(m) -mutex_trylock(&(m)->mutex)
+# define pthread_mutex_give(m) -mutex_unlock(&(m)->mutex)
+# define pthread_mutex_breaklock(m,v) -mutex_breaklock(&(m)->mutex,v)
+# define pthread_mutex_restorelock(m,v) -mutex_restorelock(&(m)->mutex,v)
+#endif
+
+#endif /* __INCLUDE_LIBS_LIBC_PTHREAD_H */
\ No newline at end of file
diff --git a/sched/pthread/pthread_condbroadcast.c
b/libs/libc/pthread/pthread_condbroadcast.c
similarity index 97%
rename from sched/pthread/pthread_condbroadcast.c
rename to libs/libc/pthread/pthread_condbroadcast.c
index f67556009fd..dd624bf3e5a 100644
--- a/sched/pthread/pthread_condbroadcast.c
+++ b/libs/libc/pthread/pthread_condbroadcast.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * sched/pthread/pthread_condbroadcast.c
+ * libs/libc/pthread/pthread_condbroadcast.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -33,7 +33,7 @@
#include <nuttx/atomic.h>
-#include "pthread/pthread.h"
+#include "pthread.h"
/****************************************************************************
* Public Functions
diff --git a/sched/pthread/pthread_condclockwait.c
b/libs/libc/pthread/pthread_condclockwait.c
similarity index 96%
rename from sched/pthread/pthread_condclockwait.c
rename to libs/libc/pthread/pthread_condclockwait.c
index 7a95bbf8b54..6bd82ab5742 100644
--- a/sched/pthread/pthread_condclockwait.c
+++ b/libs/libc/pthread/pthread_condclockwait.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * sched/pthread/pthread_condclockwait.c
+ * libs/libc/pthread/pthread_condclockwait.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -42,11 +42,9 @@
#include <nuttx/signal.h>
#include <nuttx/cancelpt.h>
#include <nuttx/pthread.h>
+#include <nuttx/atomic.h>
-#include "sched/sched.h"
-#include "pthread/pthread.h"
-#include "clock/clock.h"
-#include "signal/signal.h"
+#include "pthread.h"
/****************************************************************************
* Public Functions
diff --git a/sched/pthread/pthread_condsignal.c
b/libs/libc/pthread/pthread_condsignal.c
similarity index 97%
rename from sched/pthread/pthread_condsignal.c
rename to libs/libc/pthread/pthread_condsignal.c
index 06a362836bc..fac8a6f0153 100644
--- a/sched/pthread/pthread_condsignal.c
+++ b/libs/libc/pthread/pthread_condsignal.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * sched/pthread/pthread_condsignal.c
+ * libs/libc/pthread/pthread_condsignal.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -32,7 +32,7 @@
#include <nuttx/atomic.h>
-#include "pthread/pthread.h"
+#include "pthread.h"
/****************************************************************************
* Public Functions
diff --git a/sched/pthread/pthread_condwait.c
b/libs/libc/pthread/pthread_condwait.c
similarity index 98%
rename from sched/pthread/pthread_condwait.c
rename to libs/libc/pthread/pthread_condwait.c
index 60b774db2c1..40d8f930f89 100644
--- a/sched/pthread/pthread_condwait.c
+++ b/libs/libc/pthread/pthread_condwait.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * sched/pthread/pthread_condwait.c
+ * libs/libc/pthread/pthread_condwait.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -36,7 +36,7 @@
#include <nuttx/cancelpt.h>
#include <nuttx/pthread.h>
-#include "pthread/pthread.h"
+#include "pthread.h"
/****************************************************************************
* Public Functions
diff --git a/libs/libc/pthread/pthread_mutex.c
b/libs/libc/pthread/pthread_mutex.c
index 8caa4175610..1d65d545916 100644
--- a/libs/libc/pthread/pthread_mutex.c
+++ b/libs/libc/pthread/pthread_mutex.c
@@ -36,6 +36,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Private Functions
****************************************************************************/
diff --git a/libs/libc/pthread/pthread_mutex_consistent.c
b/libs/libc/pthread/pthread_mutex_consistent.c
index 2633c497935..a89c3ed6a39 100644
--- a/libs/libc/pthread/pthread_mutex_consistent.c
+++ b/libs/libc/pthread/pthread_mutex_consistent.c
@@ -35,6 +35,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/pthread/pthread_mutex_destroy.c
b/libs/libc/pthread/pthread_mutex_destroy.c
index 88e09746a64..8bfb6cf1686 100644
--- a/libs/libc/pthread/pthread_mutex_destroy.c
+++ b/libs/libc/pthread/pthread_mutex_destroy.c
@@ -36,6 +36,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/sched/pthread/pthread_mutexinconsistent.c
b/libs/libc/pthread/pthread_mutex_inconsistent.c
similarity index 92%
rename from sched/pthread/pthread_mutexinconsistent.c
rename to libs/libc/pthread/pthread_mutex_inconsistent.c
index cc7349e77c1..e310c5e35ab 100644
--- a/sched/pthread/pthread_mutexinconsistent.c
+++ b/libs/libc/pthread/pthread_mutex_inconsistent.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * sched/pthread/pthread_mutexinconsistent.c
+ * libs/libc/pthread/pthread_mutex_inconsistent.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -34,9 +34,9 @@
#include <nuttx/sched.h>
#include <nuttx/semaphore.h>
#include <nuttx/pthread.h>
+#include <nuttx/atomic.h>
-#include "pthread/pthread.h"
-#include "sched/sched.h"
+#include "pthread.h"
/****************************************************************************
* Public Functions
@@ -60,12 +60,9 @@
*
****************************************************************************/
-void pthread_mutex_inconsistent(FAR struct tcb_s *tcb)
+void pthread_mutex_inconsistent(FAR struct tls_info_s *tls)
{
FAR struct pthread_mutex_s *mutex;
- FAR struct tls_info_s *tls = nxsched_get_tls(tcb);
-
- DEBUGASSERT(tcb != NULL);
nxmutex_lock(&tls->tl_lock);
diff --git a/libs/libc/pthread/pthread_mutex_init.c
b/libs/libc/pthread/pthread_mutex_init.c
index 7b63cbb00d4..87655594499 100644
--- a/libs/libc/pthread/pthread_mutex_init.c
+++ b/libs/libc/pthread/pthread_mutex_init.c
@@ -34,6 +34,8 @@
#include <nuttx/semaphore.h>
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/pthread/pthread_mutex_timedlock.c
b/libs/libc/pthread/pthread_mutex_timedlock.c
index 012d2ac7ece..89cf835720e 100644
--- a/libs/libc/pthread/pthread_mutex_timedlock.c
+++ b/libs/libc/pthread/pthread_mutex_timedlock.c
@@ -36,6 +36,8 @@
#include <nuttx/sched.h>
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/pthread/pthread_mutex_trylock.c
b/libs/libc/pthread/pthread_mutex_trylock.c
index 2c2a627bd32..424a418ae74 100644
--- a/libs/libc/pthread/pthread_mutex_trylock.c
+++ b/libs/libc/pthread/pthread_mutex_trylock.c
@@ -35,6 +35,8 @@
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/pthread/pthread_mutex_unlock.c
b/libs/libc/pthread/pthread_mutex_unlock.c
index 1708a0b3118..cbe1528f53e 100644
--- a/libs/libc/pthread/pthread_mutex_unlock.c
+++ b/libs/libc/pthread/pthread_mutex_unlock.c
@@ -35,6 +35,8 @@
#include <nuttx/pthread.h>
+#include "pthread.h"
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/semaphore/sem_wait.c b/libs/libc/semaphore/sem_wait.c
index ca39cf6587a..36fb106bfc5 100644
--- a/libs/libc/semaphore/sem_wait.c
+++ b/libs/libc/semaphore/sem_wait.c
@@ -200,3 +200,75 @@ int nxsem_wait(FAR sem_t *sem)
return nxsem_wait_slow(sem);
}
+
+/****************************************************************************
+ * Name: nxsem_wait_uninterruptible
+ *
+ * Description:
+ * This function is wrapped version of nxsem_wait(), which is
+ * uninterruptible and convenient for use.
+ *
+ * Parameters:
+ * sem - Semaphore descriptor.
+ *
+ * Return Value:
+ * Zero(OK) - On success
+ * EINVAL - Invalid attempt to get the semaphore
+ * ECANCELED - May be returned if the thread is canceled while waiting.
+ *
+ ****************************************************************************/
+
+int nxsem_wait_uninterruptible(FAR sem_t *sem)
+{
+ int ret;
+
+ do
+ {
+ /* Take the semaphore (perhaps waiting) */
+
+ ret = nxsem_wait(sem);
+ }
+ while (ret == -EINTR);
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: nxsem_clockwait_uninterruptible
+ *
+ * Description:
+ * This function is wrapped version of nxsem_clockwait(), which is
+ * uninterruptible and convenient for use.
+ *
+ * Input Parameters:
+ * sem - Semaphore object
+ * clockid - The timing source to use in the conversion
+ * abstime - The absolute time to wait until a timeout is declared.
+ *
+ * Returned Value:
+ * EINVAL The sem argument does not refer to a valid semaphore. Or the
+ * thread would have blocked, and the abstime parameter specified
+ * a nanoseconds field value less than zero or greater than or
+ * equal to 1000 million.
+ * ETIMEDOUT The semaphore could not be locked before the specified timeout
+ * expired.
+ * EDEADLK A deadlock condition was detected.
+ * ECANCELED May be returned if the thread is canceled while waiting.
+ *
+ ****************************************************************************/
+
+int nxsem_clockwait_uninterruptible(FAR sem_t *sem, clockid_t clockid,
+ FAR const struct timespec *abstime)
+{
+ int ret;
+
+ do
+ {
+ /* Take the semaphore (perhaps waiting) */
+
+ ret = nxsem_clockwait(sem, clockid, abstime);
+ }
+ while (ret == -EINTR);
+
+ return ret;
+}
diff --git a/sched/pthread/CMakeLists.txt b/sched/pthread/CMakeLists.txt
index 481e2133da2..93184c7ec94 100644
--- a/sched/pthread/CMakeLists.txt
+++ b/sched/pthread/CMakeLists.txt
@@ -29,10 +29,6 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_detach.c
pthread_getschedparam.c
pthread_setschedparam.c
- pthread_condwait.c
- pthread_condsignal.c
- pthread_condbroadcast.c
- pthread_condclockwait.c
pthread_sigmask.c
pthread_cancel.c
pthread_completejoin.c
@@ -40,10 +36,6 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_release.c
pthread_setschedprio.c)
- if(NOT CONFIG_PTHREAD_MUTEX_UNSAFE)
- list(APPEND SRCS pthread_mutexinconsistent.c)
- endif()
-
if(CONFIG_SMP)
list(APPEND SRCS pthread_setaffinity.c pthread_getaffinity.c)
endif()
diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs
index 66fa744fe2e..5cf99995dd2 100644
--- a/sched/pthread/Make.defs
+++ b/sched/pthread/Make.defs
@@ -24,15 +24,10 @@ ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += pthread_create.c pthread_exit.c pthread_join.c pthread_detach.c
CSRCS += pthread_getschedparam.c pthread_setschedparam.c
-CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c
-CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c
+CSRCS += pthread_sigmask.c pthread_cancel.c
CSRCS += pthread_completejoin.c pthread_findjoininfo.c
CSRCS += pthread_release.c pthread_setschedprio.c
-ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
-CSRCS += pthread_mutexinconsistent.c
-endif
-
ifeq ($(CONFIG_SMP),y)
CSRCS += pthread_setaffinity.c pthread_getaffinity.c
endif
diff --git a/sched/pthread/pthread.h b/sched/pthread/pthread.h
index 6737eeda98b..7d8e10e1128 100644
--- a/sched/pthread/pthread.h
+++ b/sched/pthread/pthread.h
@@ -42,8 +42,6 @@
* Pre-processor Definitions
****************************************************************************/
-#define COND_WAIT_COUNT(cond) ((FAR atomic_t *)&(cond)->wait_count)
-
/****************************************************************************
* Public Data
****************************************************************************/
@@ -73,7 +71,7 @@ int pthread_findjoininfo(FAR struct task_group_s *group,
pid_t pid,
void pthread_release(FAR struct task_group_s *group);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
-void pthread_mutex_inconsistent(FAR struct tcb_s *tcb);
+void pthread_mutex_inconsistent(FAR struct tls_info_s *tls);
#endif
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
diff --git a/sched/semaphore/sem_clockwait.c b/sched/semaphore/sem_clockwait.c
index f94ac81e809..dadc3cbb544 100644
--- a/sched/semaphore/sem_clockwait.c
+++ b/sched/semaphore/sem_clockwait.c
@@ -150,42 +150,3 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
return ret;
}
-/****************************************************************************
- * Name: nxsem_clockwait_uninterruptible
- *
- * Description:
- * This function is wrapped version of nxsem_clockwait(), which is
- * uninterruptible and convenient for use.
- *
- * Input Parameters:
- * sem - Semaphore object
- * clockid - The timing source to use in the conversion
- * abstime - The absolute time to wait until a timeout is declared.
- *
- * Returned Value:
- * EINVAL The sem argument does not refer to a valid semaphore. Or the
- * thread would have blocked, and the abstime parameter specified
- * a nanoseconds field value less than zero or greater than or
- * equal to 1000 million.
- * ETIMEDOUT The semaphore could not be locked before the specified timeout
- * expired.
- * EDEADLK A deadlock condition was detected.
- * ECANCELED May be returned if the thread is canceled while waiting.
- *
- ****************************************************************************/
-
-int nxsem_clockwait_uninterruptible(FAR sem_t *sem, clockid_t clockid,
- FAR const struct timespec *abstime)
-{
- int ret;
-
- do
- {
- /* Take the semaphore (perhaps waiting) */
-
- ret = nxsem_clockwait(sem, clockid, abstime);
- }
- while (ret == -EINTR);
-
- return ret;
-}
diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c
index 002f35c034c..899263de84d 100644
--- a/sched/semaphore/sem_wait.c
+++ b/sched/semaphore/sem_wait.c
@@ -283,35 +283,3 @@ int nxsem_wait_slow(FAR sem_t *sem)
leave_critical_section(flags);
return ret;
}
-
-/****************************************************************************
- * Name: nxsem_wait_uninterruptible
- *
- * Description:
- * This function is wrapped version of nxsem_wait(), which is
- * uninterruptible and convenient for use.
- *
- * Parameters:
- * sem - Semaphore descriptor.
- *
- * Return Value:
- * Zero(OK) - On success
- * EINVAL - Invalid attempt to get the semaphore
- * ECANCELED - May be returned if the thread is canceled while waiting.
- *
- ****************************************************************************/
-
-int nxsem_wait_uninterruptible(FAR sem_t *sem)
-{
- int ret;
-
- do
- {
- /* Take the semaphore (perhaps waiting) */
-
- ret = nxsem_wait(sem);
- }
- while (ret == -EINTR);
-
- return ret;
-}
diff --git a/sched/task/task_recover.c b/sched/task/task_recover.c
index cd5ec15a77e..ecdbb9d2dbf 100644
--- a/sched/task/task_recover.c
+++ b/sched/task/task_recover.c
@@ -67,7 +67,7 @@ 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);
+ pthread_mutex_inconsistent(nxsched_get_tls(tcb));
#endif
/* The task is being deleted. Cancel in pending timeout events. */
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index dce508f0710..6bbd2645231 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -110,10 +110,6 @@
"pread","unistd.h","","ssize_t","int","FAR void *","size_t","off_t"
"pselect","sys/select.h","!defined(CONFIG_DISABLE_ALL_SIGNALS)","int","int","FAR
fd_set *","FAR fd_set *","FAR fd_set *","FAR const struct timespec *","FAR
const sigset_t *"
"pthread_cancel","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t"
-"pthread_cond_broadcast","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
pthread_cond_t *"
-"pthread_cond_clockwait","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
pthread_cond_t *","FAR pthread_mutex_t *","clockid_t","FAR const struct
timespec *"
-"pthread_cond_signal","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
pthread_cond_t *"
-"pthread_cond_wait","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
pthread_cond_t *","FAR pthread_mutex_t *"
"pthread_detach","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t"
"pthread_getaffinity_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD) &&
defined(CONFIG_SMP)","int","pthread_t","size_t","FAR cpu_set_t*"
"pthread_getschedparam","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","FAR
int *","FAR struct sched_param *"