diff --git a/sched/pthread/CMakeLists.txt b/sched/pthread/CMakeLists.txt index 50418ddff1d..da24530c836 100644 --- a/sched/pthread/CMakeLists.txt +++ b/sched/pthread/CMakeLists.txt @@ -40,7 +40,6 @@ if(NOT CONFIG_DISABLE_PTHREAD) pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c - pthread_sem.c pthread_completejoin.c pthread_findjoininfo.c pthread_release.c diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs index c44e9a02a6b..209f11ef95c 100644 --- a/sched/pthread/Make.defs +++ b/sched/pthread/Make.defs @@ -28,7 +28,7 @@ CSRCS += pthread_mutexinit.c pthread_mutexdestroy.c CSRCS += pthread_mutextimedlock.c pthread_mutextrylock.c pthread_mutexunlock.c CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c -CSRCS += pthread_sem.c pthread_completejoin.c pthread_findjoininfo.c +CSRCS += pthread_completejoin.c pthread_findjoininfo.c CSRCS += pthread_release.c pthread_setschedprio.c CSRCS += pthread_barrierwait.c diff --git a/sched/pthread/pthread.h b/sched/pthread/pthread.h index f99c25b94ba..d6c3bd76adf 100644 --- a/sched/pthread/pthread.h +++ b/sched/pthread/pthread.h @@ -107,12 +107,6 @@ int pthread_findjoininfo(FAR struct task_group_s *group, pid_t pid, FAR struct task_join_s **join, bool create); void pthread_release(FAR struct task_group_s *group); -int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout); -#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE -int pthread_sem_trytake(FAR sem_t *sem); -#endif -int pthread_sem_give(FAR sem_t *sem); - #ifndef CONFIG_PTHREAD_MUTEX_UNSAFE int pthread_mutex_take(FAR struct pthread_mutex_s *mutex, FAR const struct timespec *abs_timeout); diff --git a/sched/pthread/pthread_condbroadcast.c b/sched/pthread/pthread_condbroadcast.c index 99127716470..599bd976c23 100644 --- a/sched/pthread/pthread_condbroadcast.c +++ b/sched/pthread/pthread_condbroadcast.c @@ -90,7 +90,7 @@ int pthread_cond_broadcast(FAR pthread_cond_t *cond) * Only the highest priority waiting thread will get to execute */ - ret = pthread_sem_give(&cond->sem); + ret = -nxsem_post(&cond->sem); /* Increment the semaphore count (as was done by the * above post). diff --git a/sched/pthread/pthread_condsignal.c b/sched/pthread/pthread_condsignal.c index eed49a73f4e..fb9453b712e 100644 --- a/sched/pthread/pthread_condsignal.c +++ b/sched/pthread/pthread_condsignal.c @@ -93,7 +93,7 @@ int pthread_cond_signal(FAR pthread_cond_t *cond) if (sval < 0) { sinfo("Signalling...\n"); - ret = pthread_sem_give(&cond->sem); + ret = -nxsem_post(&cond->sem); } } } diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c index 2820c95137a..fbc914897c9 100644 --- a/sched/pthread/pthread_condwait.c +++ b/sched/pthread/pthread_condwait.c @@ -97,7 +97,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex) * or if the thread is canceled (ECANCELED) */ - status = pthread_sem_take(&cond->sem, NULL); + status = -nxsem_wait_uninterruptible(&cond->sem); if (ret == OK) { /* Report the first failure that occurs */ diff --git a/sched/pthread/pthread_sem.c b/sched/pthread/pthread_sem.c deleted file mode 100644 index cea0e6bfe0c..00000000000 --- a/sched/pthread/pthread_sem.c +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * sched/pthread/pthread_sem.c - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include - -#include "pthread/pthread.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: pthread_sem_take, pthread_sem_trytake, and - * pthread_sem_give - * - * Description: - * Support managed access to the private data sets. - * - * REVISIT: These functions really do nothing more than match the return - * value of the semaphore functions (0 or -1 with errno set) to the - * return value of more pthread functions (0 or errno). A better solution - * would be to use an internal version of the semaphore functions that - * return the error value in the correct form. - * - * Input Parameters: - * sem - The semaphore to lock or unlock - * - * Returned Value: - * 0 on success or an errno value on failure. - * - ****************************************************************************/ - -int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout) -{ - int ret; - - if (abs_timeout == NULL) - { - ret = nxsem_wait_uninterruptible(sem); - } - else - { - ret = nxsem_timedwait_uninterruptible(sem, abs_timeout); - } - - return -ret; -} - -#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE -int pthread_sem_trytake(FAR sem_t *sem) -{ - int ret = EINVAL; - - /* Verify input parameters */ - - DEBUGASSERT(sem != NULL); - if (sem != NULL) - { - /* Try to take the semaphore */ - - int status = nxsem_trywait(sem); - ret = status < 0 ? -status : OK; - } - - return ret; -} -#endif - -int pthread_sem_give(FAR sem_t *sem) -{ - int ret; - - /* Verify input parameters */ - - DEBUGASSERT(sem != NULL); - if (sem != NULL) - { - /* Give the semaphore */ - - ret = nxsem_post(sem); - if (ret < 0) - { - return -ret; - } - - return OK; - } - else - { - /* NULL semaphore pointer! */ - - return EINVAL; - } -}