From d189a86a35482fc20951031e2b9bcb39929deef9 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Sun, 23 Apr 2023 14:45:14 +0800 Subject: [PATCH] system: pthread_barrierwait should be moved to kernel space The current implementation requires the use of enter_critical_section, so the source code needs to be moved to kernel space Signed-off-by: hujun5 --- include/sys/syscall_lookup.h | 1 + libs/libc/pthread/Make.defs | 2 +- sched/pthread/Make.defs | 1 + {libs/libc => sched}/pthread/pthread_barrierwait.c | 2 +- syscall/syscall.csv | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) rename {libs/libc => sched}/pthread/pthread_barrierwait.c (99%) diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h index e376fe2821..d26ae4f061 100644 --- a/include/sys/syscall_lookup.h +++ b/include/sys/syscall_lookup.h @@ -301,6 +301,7 @@ 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) diff --git a/libs/libc/pthread/Make.defs b/libs/libc/pthread/Make.defs index 138fe8befe..c236fd1a2b 100644 --- a/libs/libc/pthread/Make.defs +++ b/libs/libc/pthread/Make.defs @@ -37,7 +37,7 @@ CSRCS += pthread_attr_setstack.c pthread_attr_getstack.c CSRCS += pthread_attr_setschedparam.c pthread_attr_getschedparam.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 pthread_barrierwait.c +CSRCS += pthread_barrierinit.c pthread_barrierdestroy.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 diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs index 6913a8dee0..d8d7cb8928 100644 --- a/sched/pthread/Make.defs +++ b/sched/pthread/Make.defs @@ -28,6 +28,7 @@ CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c CSRCS += pthread_initialize.c 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 diff --git a/libs/libc/pthread/pthread_barrierwait.c b/sched/pthread/pthread_barrierwait.c similarity index 99% rename from libs/libc/pthread/pthread_barrierwait.c rename to sched/pthread/pthread_barrierwait.c index 9e3f3dcfb0..add1748b56 100644 --- a/libs/libc/pthread/pthread_barrierwait.c +++ b/sched/pthread/pthread_barrierwait.c @@ -1,5 +1,5 @@ /**************************************************************************** - * libs/libc/pthread/pthread_barrierwait.c + * sched/pthread/pthread_barrierwait.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/syscall/syscall.csv b/syscall/syscall.csv index f0da801949..6315060f20 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -92,6 +92,7 @@ "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 *"