Skip to content

Commit

Permalink
Revert "system: pthread_barrierwait should be moved to kernel space"
Browse files Browse the repository at this point in the history
reason:
new implementation does not requires the use of enter_critical_section,
so the source code needs to be moved to user space

This reverts commit d189a86.
  • Loading branch information
hujun260 authored and xiaoxiang781216 committed Nov 15, 2024
1 parent 238cddd commit dcc7504
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion include/sys/syscall_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ SYSCALL_LOOKUP(munmap, 2)
/* The following are defined if pthreads are enabled */

#ifndef CONFIG_DISABLE_PTHREAD
SYSCALL_LOOKUP(pthread_barrier_wait, 1)
SYSCALL_LOOKUP(pthread_cancel, 1)
SYSCALL_LOOKUP(pthread_cond_broadcast, 1)
SYSCALL_LOOKUP(pthread_cond_signal, 1)
Expand Down
1 change: 1 addition & 0 deletions libs/libc/pthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_barrierattr_setpshared.c
pthread_barrierinit.c
pthread_barrierdestroy.c
pthread_barrierwait.c
pthread_condattr_init.c
pthread_condattr_destroy.c
pthread_condattr_getpshared.c
Expand Down
2 changes: 1 addition & 1 deletion libs/libc/pthread/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CSRCS += pthread_attr_setschedparam.c pthread_attr_getschedparam.c
CSRCS += pthread_attr_setscope.c pthread_attr_getscope.c
CSRCS += pthread_barrierattr_init.c pthread_barrierattr_destroy.c
CSRCS += pthread_barrierattr_getpshared.c pthread_barrierattr_setpshared.c
CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c
CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c pthread_barrierwait.c
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* sched/pthread/pthread_barrierwait.c
* libs/libc/pthread/pthread_barrierwait.c
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -112,5 +112,16 @@ int pthread_barrier_wait(FAR pthread_barrier_t *barrier)

nxmutex_unlock(&barrier->mutex);

return -nxsem_wait_uninterruptible(&barrier->sem);
while (sem_wait(&barrier->sem) != OK)
{
/* If the thread is awakened by a signal, just continue to wait */

int errornumber = get_errno();
if (errornumber != EINTR)
{
return errornumber;
}
}

return OK;
}
3 changes: 1 addition & 2 deletions sched/pthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_completejoin.c
pthread_findjoininfo.c
pthread_release.c
pthread_setschedprio.c
pthread_barrierwait.c)
pthread_setschedprio.c)

if(NOT CONFIG_PTHREAD_MUTEX_UNSAFE)
list(APPEND SRCS pthread_mutex.c pthread_mutexconsistent.c
Expand Down
1 change: 0 additions & 1 deletion sched/pthread/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c
CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c
CSRCS += pthread_completejoin.c pthread_findjoininfo.c
CSRCS += pthread_release.c pthread_setschedprio.c
CSRCS += pthread_barrierwait.c

ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
CSRCS += pthread_mutex.c pthread_mutexconsistent.c pthread_mutexinconsistent.c
Expand Down
1 change: 0 additions & 1 deletion syscall/syscall.csv
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
"prctl","sys/prctl.h","","int","int","...","uintptr_t","uintptr_t"
"pread","unistd.h","","ssize_t","int","FAR void *","size_t","off_t"
"pselect","sys/select.h","","int","int","FAR fd_set *","FAR fd_set *","FAR fd_set *","FAR const struct timespec *","FAR const sigset_t *"
"pthread_barrier_wait","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_barrier_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 *"
Expand Down

0 comments on commit dcc7504

Please sign in to comment.