mirror of
https://github.com/apache/nuttx.git
synced 2026-03-23 22:43:57 +08:00
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 <hujun5@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
****************************************************************************/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
99
libs/libc/pthread/pthread.h
Normal file
99
libs/libc/pthread/pthread.h
Normal file
@@ -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 */
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <nuttx/pthread.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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 *"
|
||||
|
||||
|
Reference in New Issue
Block a user