diff --git a/doc/services/portability/posix/conformance/index.rst b/doc/services/portability/posix/conformance/index.rst index 23faa7568fa01..31ada80eb7b76 100644 --- a/doc/services/portability/posix/conformance/index.rst +++ b/doc/services/portability/posix/conformance/index.rst @@ -96,7 +96,7 @@ POSIX System Interfaces _POSIX_TYPED_MEMORY_OBJECTS, -1, _XOPEN_CRYPT, -1, :ref:`_XOPEN_REALTIME `, 700, :kconfig:option:`CONFIG_XSI_REALTIME` - _XOPEN_REALTIME_THREADS, -1, + :ref:`_XOPEN_REALTIME `, 700, :kconfig:option:`CONFIG_XSI_REALTIME_THREADS` :ref:`_XOPEN_STREAMS`, 200809L, :kconfig:option:`CONFIG_XOPEN_STREAMS` _XOPEN_UNIX, -1, diff --git a/doc/services/portability/posix/option_groups/index.rst b/doc/services/portability/posix/option_groups/index.rst index 2f4bf18a9bfe9..31c7eb80666c9 100644 --- a/doc/services/portability/posix/option_groups/index.rst +++ b/doc/services/portability/posix/option_groups/index.rst @@ -706,6 +706,24 @@ Enable this option group with :kconfig:option:`CONFIG_XSI_REALTIME`. When this option group is enabled, the ``_XOPEN_REALTIME`` feature test macro will be defined to a value other than -1. +.. _posix_option_group_xsi_realtime_threads: + +XSI_REALTIME_THREADS +++++++++++++++++++++ + +The ``XSI_REALTIME_THREADS`` option group indicates that the +:ref:`_POSIX_THREAD_PRIO_INHERIT`, +:ref:`_POSIX_THREAD_PRIO_PROTECT`, +:ref:`_POSIX_THREAD_PRIORITY_SCHEDULING`, +:ref:`_POSIX_THREAD_ROBUST_PRIO_INHERIT`, and +:ref:`_POSIX_THREAD_ROBUST_PRIO_PROTECT` options are +enabled. + +Enable this option group with :kconfig:option:`CONFIG_XSI_REALTIME_THREADS`. + +When this option group is enabled, the ``_XOPEN_REALTIME_THREADS`` feature test macro will be defined to a +value other than -1. + .. _posix_option_group_xsi_single_process: XSI_SINGLE_PROCESS @@ -1051,6 +1069,10 @@ Enable this option with :kconfig:option:`CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING pthread_setschedparam(),yes pthread_setschedprio(),yes +.. _posix_option_thread_robust_prio_inherit: + +.. _posix_option_thread_robust_prio_protect: + .. _posix_option_thread_safe_functions: _POSIX_THREAD_SAFE_FUNCTIONS diff --git a/include/zephyr/posix/posix_features.h b/include/zephyr/posix/posix_features.h index b253dbd8fc5a7..7c3085793fc26 100644 --- a/include/zephyr/posix/posix_features.h +++ b/include/zephyr/posix/posix_features.h @@ -132,21 +132,7 @@ #define _POSIX_THREAD_CPUTIME _POSIX_VERSION #endif -#ifdef CONFIG_POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT _POSIX_VERSION -#endif - -#ifdef CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION -#endif - /* #define _POSIX_THREAD_PROCESS_SHARED (-1L) */ -/* #define _POSIX_THREAD_ROBUST_PRIO_INHERIT (-1L) */ -/* #define _POSIX_THREAD_ROBUST_PRIO_PROTECT (-1L) */ /* #define _POSIX_THREAD_SPORADIC_SERVER (-1L) */ @@ -214,7 +200,7 @@ defined(CONFIG_POSIX_SHARED_MEMORY_OBJECTS) && defined(CONFIG_POSIX_SYNCHRONIZED_IO)) #define _XOPEN_REALTIME _XOPEN_VERSION #endif -/* #define _XOPEN_REALTIME_THREADS (-1L) */ + /* #define _XOPEN_SHM (-1L) */ #ifdef CONFIG_XOPEN_STREAMS diff --git a/include/zephyr/posix/pthread.h b/include/zephyr/posix/pthread.h index 8b9b03e490c54..7d590a050ecf4 100644 --- a/include/zephyr/posix/pthread.h +++ b/include/zephyr/posix/pthread.h @@ -33,21 +33,21 @@ extern "C" { #define PTHREAD_PROCESS_SHARED 1 /* Pthread cancellation */ -#define PTHREAD_CANCELED ((void *)-1) -#define PTHREAD_CANCEL_ENABLE 0 -#define PTHREAD_CANCEL_DISABLE 1 +#define PTHREAD_CANCELED ((void *)-1) +#define PTHREAD_CANCEL_ENABLE 0 +#define PTHREAD_CANCEL_DISABLE 1 #define PTHREAD_CANCEL_DEFERRED 0 #define PTHREAD_CANCEL_ASYNCHRONOUS 1 /* Pthread scope */ #undef PTHREAD_SCOPE_PROCESS -#define PTHREAD_SCOPE_PROCESS 1 +#define PTHREAD_SCOPE_PROCESS 1 #undef PTHREAD_SCOPE_SYSTEM -#define PTHREAD_SCOPE_SYSTEM 0 +#define PTHREAD_SCOPE_SYSTEM 0 /* Pthread inherit scheduler */ #undef PTHREAD_INHERIT_SCHED -#define PTHREAD_INHERIT_SCHED 0 +#define PTHREAD_INHERIT_SCHED 0 #undef PTHREAD_EXPLICIT_SCHED #define PTHREAD_EXPLICIT_SCHED 1 @@ -130,7 +130,7 @@ int pthread_condattr_destroy(pthread_condattr_t *att); * */ int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT att, - clockid_t *ZRESTRICT clock_id); + clockid_t *ZRESTRICT clock_id); /** * @brief POSIX threading compatibility API @@ -165,10 +165,10 @@ int pthread_condattr_setclock(pthread_condattr_t *att, clockid_t clock_id); * error is returned. * */ -#define PTHREAD_MUTEX_NORMAL 0 -#define PTHREAD_MUTEX_RECURSIVE 1 -#define PTHREAD_MUTEX_ERRORCHECK 2 -#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_RECURSIVE 1 +#define PTHREAD_MUTEX_ERRORCHECK 2 +#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL /* * Mutex attributes - protocol @@ -182,9 +182,9 @@ int pthread_condattr_setclock(pthread_condattr_t *att, clockid_t clock_id); * any of these mutexes). * FIXME: Only PRIO_NONE is supported. Implement other protocols. */ -#define PTHREAD_PRIO_NONE 0 -#define PTHREAD_PRIO_INHERIT 1 -#define PTHREAD_PRIO_PROTECT 2 +#define PTHREAD_PRIO_NONE 0 +#define PTHREAD_PRIO_INHERIT 1 +#define PTHREAD_PRIO_PROTECT 2 /** * @brief POSIX threading compatibility API @@ -213,8 +213,7 @@ int pthread_mutex_unlock(pthread_mutex_t *m); * See IEEE 1003.1 */ -int pthread_mutex_timedlock(pthread_mutex_t *m, - const struct timespec *abstime); +int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *abstime); /** * @brief POSIX threading compatibility API @@ -228,15 +227,7 @@ int pthread_mutex_trylock(pthread_mutex_t *m); * * See IEEE 1003.1 */ -int pthread_mutex_init(pthread_mutex_t *m, - const pthread_mutexattr_t *att); - -/** - * @brief POSIX threading compatibility API - * - * See IEEE 1003.1 - */ -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol); +int pthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *att); /** * @brief POSIX threading compatibility API @@ -245,14 +236,6 @@ int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol); */ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type); -/** - * @brief POSIX threading compatibility API - * - * See IEEE 1003.1 - */ -int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, - int *protocol); - /** * @brief POSIX threading compatibility API * @@ -283,8 +266,8 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); /* * Barrier attributes - type */ -#define PTHREAD_PROCESS_PRIVATE 0 -#define PTHREAD_PROCESS_PUBLIC 1 +#define PTHREAD_PROCESS_PRIVATE 0 +#define PTHREAD_PROCESS_PUBLIC 1 /** * @brief POSIX threading compatibility API @@ -356,16 +339,6 @@ int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); */ -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT -int pthread_mutex_getprioceiling(const pthread_mutex_t *ZRESTRICT mutex, - int *ZRESTRICT prioceiling); -int pthread_mutex_setprioceiling(pthread_mutex_t *ZRESTRICT mutex, int prioceiling, - int *ZRESTRICT old_ceiling); -int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr, - int *ZRESTRICT prioceiling); -int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling); -#endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */ - /* Base Pthread related APIs */ /** @@ -413,18 +386,30 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); int pthread_attr_init(pthread_attr_t *attr); int pthread_attr_destroy(pthread_attr_t *attr); -int pthread_attr_getschedparam(const pthread_attr_t *attr, - struct sched_param *schedparam); -int pthread_getschedparam(pthread_t pthread, int *policy, - struct sched_param *param); -int pthread_attr_getstack(const pthread_attr_t *attr, - void **stackaddr, size_t *stacksize); -int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, - size_t stacksize); -int pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope); +int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *schedparam); +int pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stacksize); +int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); + +#if defined(CONFIG_XSI_REALTIME_THREADS) +int pthread_attr_getscope(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT contentionscope); int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); -int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched); +int pthread_attr_getinheritsched(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT inheritsched); int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); +int pthread_attr_getschedpolicy(const pthread_attr_t *ZRESTRICT attr, int *ZRESTRICT policy); +int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); +int pthread_getschedparam(pthread_t thread, int *ZRESTRICT policy, + struct sched_param *ZRESTRICT param); +int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param); +int pthread_setschedprio(pthread_t thread, int prio); +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol); +int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol); +int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling); +int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling); +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *ZRESTRICT attr, + int *ZRESTRICT prioceiling); +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling); +#endif + #ifdef CONFIG_POSIX_THREADS int pthread_once(pthread_once_t *once, void (*initFunc)(void)); #endif @@ -434,30 +419,22 @@ int pthread_tryjoin_np(pthread_t thread, void **status); int pthread_join(pthread_t thread, void **status); int pthread_cancel(pthread_t pthread); int pthread_detach(pthread_t thread); -int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, - void *(*threadroutine)(void *), void *arg); +int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*threadroutine)(void *), + void *arg); int pthread_setcancelstate(int state, int *oldstate); int pthread_setcanceltype(int type, int *oldtype); void pthread_testcancel(void); -int pthread_attr_setschedparam(pthread_attr_t *attr, - const struct sched_param *schedparam); -int pthread_setschedparam(pthread_t pthread, int policy, - const struct sched_param *param); -int pthread_setschedprio(pthread_t thread, int prio); +int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *schedparam); int pthread_rwlock_destroy(pthread_rwlock_t *rwlock); -int pthread_rwlock_init(pthread_rwlock_t *rwlock, - const pthread_rwlockattr_t *attr); +int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr); int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock); -int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, - const struct timespec *abstime); -int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, - const struct timespec *abstime); +int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abstime); +int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abstime); int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock); int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock); int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock); -int pthread_key_create(pthread_key_t *key, - void (*destructor)(void *)); +int pthread_key_create(pthread_key_t *key, void (*destructor)(void *)); int pthread_key_delete(pthread_key_t key); int pthread_setspecific(pthread_key_t key, const void *value); void *pthread_getspecific(pthread_key_t key); @@ -471,11 +448,12 @@ void __z_pthread_cleanup_pop(int execute); #define pthread_cleanup_push(_rtn, _arg) \ do /* enforce '{'-like behaviour */ { \ void *_z_pthread_cleanup[3]; \ - __z_pthread_cleanup_push(_z_pthread_cleanup, _rtn, _arg) + __z_pthread_cleanup_push(_z_pthread_cleanup, _rtn, _arg) #define pthread_cleanup_pop(_ex) \ - __z_pthread_cleanup_pop(_ex); \ - } /* enforce '}'-like behaviour */ while (0) + __z_pthread_cleanup_pop(_ex); \ + } /* enforce '}'-like behaviour */ \ + while (0) /* Glibc / Oracle Extension Functions */ diff --git a/lib/posix/Kconfig.toolchain b/lib/posix/Kconfig.toolchain index 4ee30a8246540..95da55a05713a 100644 --- a/lib/posix/Kconfig.toolchain +++ b/lib/posix/Kconfig.toolchain @@ -213,6 +213,9 @@ config TC_PROVIDES_XSI_MULTI_PROCESS config TC_PROVIDES_XSI_REALTIME bool +config TC_PROVIDES_XSI_REALTIME_THREADS + bool + config TC_PROVIDES_XSI_SIGNALS bool diff --git a/lib/posix/options/CMakeLists.txt b/lib/posix/options/CMakeLists.txt index 3c0a886edd2eb..ae85b427f9dec 100644 --- a/lib/posix/options/CMakeLists.txt +++ b/lib/posix/options/CMakeLists.txt @@ -165,6 +165,21 @@ if(NOT CONFIG_TC_PROVIDES_XSI_REALTIME) zephyr_library_sources_ifdef(CONFIG_POSIX_SHARED_MEMORY_OBJECTS shm.c) endif() +if(NOT CONFIG_TC_PROVIDES_XSI_REALTIME_THREADS) + zephyr_library_sources_ifdef(CONFIG_XSI_REALTIME_THREADS + xsi_realtime_threads.c + ) +endif() + +if(CONFIG_XSI_REALTIME_THREADS) + zephyr_compile_definitions(-D_XOPEN_REALTIME_THREADS=${XOPEN_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIORITY_SCHEDULING=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIO_INHERIT=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_PRIO_PROTECT=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_ROBUST_PRIO_INHERIT=${POSIX_VERSION}) + zephyr_compile_definitions(-D_POSIX_THREAD_ROBUST_PRIO_PROTECT=${POSIX_VERSION}) +endif() + zephyr_library_sources_ifdef(CONFIG_XOPEN_STREAMS stropts.c) if (NOT CONFIG_TC_PROVIDES_XSI_SINGLE_PROCESS) diff --git a/lib/posix/options/Kconfig b/lib/posix/options/Kconfig index 3f072a293f6be..6954e1434cdcd 100644 --- a/lib/posix/options/Kconfig +++ b/lib/posix/options/Kconfig @@ -30,6 +30,7 @@ menu "X/Open system interfaces" # zephyr-keep-sorted-start rsource "Kconfig.xsi_realtime" +rsource "Kconfig.xsi_realtime_threads" rsource "Kconfig.xsi_single_process" rsource "Kconfig.xsi_streams" rsource "Kconfig.xsi_system_logging" diff --git a/lib/posix/options/Kconfig.pthread b/lib/posix/options/Kconfig.pthread index 438506fe2182f..21a45c3de286b 100644 --- a/lib/posix/options/Kconfig.pthread +++ b/lib/posix/options/Kconfig.pthread @@ -99,15 +99,7 @@ config POSIX_THREADS_EXT config POSIX_THREAD_PRIORITY_SCHEDULING bool "Run POSIX threads with different priorities and schedulers" - help - Enabling this option allows the application to configure different priorities and - scheduling algorithms for different threads via functions such as pthread_setschedparam() - and pthread_setschedprio(). This is required for Realtime Threads and Advanced Realtime - Threads. - - For more information, please see - https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_01_06 - https://man7.org/linux/man-pages/man7/posixoptions.7.html + select DEPRECATED config POSIX_PTHREAD_ATTR_STACKSIZE_BITS int "Significant bits for pthread_attr_t stacksize" @@ -143,19 +135,11 @@ config POSIX_PTHREAD_ATTR_GUARDSIZE_DEFAULT config POSIX_THREAD_PRIO_INHERIT bool "POSIX mutex priority inheritance" - help - Select 'y' here to enable POSIX mutex priority inheritance. - - For more information, please see - https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_getprotocol.html + select DEPRECATED config POSIX_THREAD_PRIO_PROTECT bool "POSIX mutex priority protection" - help - Select 'y' here to enable POSIX mutex priority protection. - - For more information, please see - https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_getprotocol.html + select DEPRECATED config POSIX_THREAD_SAFE_FUNCTIONS bool "POSIX thread-safe functions" diff --git a/lib/posix/options/Kconfig.xsi_realtime_threads b/lib/posix/options/Kconfig.xsi_realtime_threads new file mode 100644 index 0000000000000..44b5ba90e90c9 --- /dev/null +++ b/lib/posix/options/Kconfig.xsi_realtime_threads @@ -0,0 +1,24 @@ +# Copyright (c) 2024 Tenstorrent AI ULC +# +# SPDX-License-Identifier: Apache-2.0 + +config XSI_REALTIME_THREADS + bool "X/Open realtime threads" + depends on POSIX_THREADS + help + Select 'y' here to enable the _POSIX_THREAD_PRIO_INHERIT, _POSIX_THREAD_PRIO_PROTECT, + _POSIX_THREAD_PRIORITY_SCHEDULING, _POSIX_THREAD_ROBUST_PRIO_INHERIT, and + _POSIX_THREAD_ROBUST_PRIO_PROTECT options. + + The feature test macro _XOPEN_REALTIME_THREADS will be defined to a value other than -1. + + For more information, please see + https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html + +if XSI_REALTIME_THREADS + +module = XSI_REALTIME_THREADS +module-str = XSI Realtime Threads +source "subsys/logging/Kconfig.template.log_config" + +endif diff --git a/lib/posix/options/mutex.c b/lib/posix/options/mutex.c index 219c6dbaf8946..f3d6e44a64016 100644 --- a/lib/posix/options/mutex.c +++ b/lib/posix/options/mutex.c @@ -28,8 +28,7 @@ static const struct pthread_mutexattr def_attr = { .type = PTHREAD_MUTEX_DEFAULT, }; -__pinned_bss -static struct k_mutex posix_mutex_pool[CONFIG_MAX_PTHREAD_MUTEX_COUNT]; +static __pinned_bss struct k_mutex posix_mutex_pool[CONFIG_MAX_PTHREAD_MUTEX_COUNT]; static uint8_t posix_mutex_type[CONFIG_MAX_PTHREAD_MUTEX_COUNT]; SYS_BITARRAY_DEFINE_STATIC(posix_mutex_bitarray, CONFIG_MAX_PTHREAD_MUTEX_COUNT); @@ -40,7 +39,7 @@ SYS_BITARRAY_DEFINE_STATIC(posix_mutex_bitarray, CONFIG_MAX_PTHREAD_MUTEX_COUNT) * the theoretical pthread_mutex_t range is [0,2147483647]. */ BUILD_ASSERT(CONFIG_MAX_PTHREAD_MUTEX_COUNT < PTHREAD_OBJ_MASK_INIT, - "CONFIG_MAX_PTHREAD_MUTEX_COUNT is too high"); + "CONFIG_MAX_PTHREAD_MUTEX_COUNT is too high"); static inline size_t posix_mutex_to_offset(struct k_mutex *m) { @@ -208,8 +207,7 @@ int pthread_mutex_trylock(pthread_mutex_t *m) * * See IEEE 1003.1 */ -int pthread_mutex_timedlock(pthread_mutex_t *m, - const struct timespec *abstime) +int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *abstime) { if ((abstime == NULL) || !timespec_is_valid(abstime)) { LOG_DBG("%s is invalid", "abstime"); @@ -249,7 +247,6 @@ int pthread_mutex_init(pthread_mutex_t *mu, const pthread_mutexattr_t *_attr) return 0; } - /** * @brief Lock POSIX mutex with blocking call. * @@ -312,45 +309,6 @@ int pthread_mutex_destroy(pthread_mutex_t *mu) return 0; } -/** - * @brief Read protocol attribute for mutex. - * - * See IEEE 1003.1 - */ -int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, - int *protocol) -{ - if ((attr == NULL) || (protocol == NULL)) { - return EINVAL; - } - - *protocol = PTHREAD_PRIO_NONE; - return 0; -} - -/** - * @brief Set protocol attribute for mutex. - * - * See IEEE 1003.1 - */ -int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) -{ - if (attr == NULL) { - return EINVAL; - } - - switch (protocol) { - case PTHREAD_PRIO_NONE: - return 0; - case PTHREAD_PRIO_INHERIT: - return ENOTSUP; - case PTHREAD_PRIO_PROTECT: - return ENOTSUP; - default: - return EINVAL; - } -} - int pthread_mutexattr_init(pthread_mutexattr_t *attr) { struct pthread_mutexattr *const a = (struct pthread_mutexattr *)attr; @@ -420,44 +378,7 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) } } -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT -int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling) -{ - ARG_UNUSED(mutex); - ARG_UNUSED(prioceiling); - - return ENOSYS; -} - -int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling) -{ - ARG_UNUSED(mutex); - ARG_UNUSED(prioceiling); - ARG_UNUSED(old_ceiling); - - return ENOSYS; -} - -int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *prioceiling) -{ - ARG_UNUSED(attr); - ARG_UNUSED(prioceiling); - - return ENOSYS; -} - -int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) -{ - ARG_UNUSED(attr); - ARG_UNUSED(prioceiling); - - return ENOSYS; -} - -#endif /* CONFIG_POSIX_THREAD_PRIO_PROTECT */ - -__boot_func -static int pthread_mutex_pool_init(void) +__boot_func static int pthread_mutex_pool_init(void) { int err; size_t i; diff --git a/lib/posix/options/posix_internal.h b/lib/posix/options/posix_internal.h index d149b51e63a62..c275931973a05 100644 --- a/lib/posix/options/posix_internal.h +++ b/lib/posix/options/posix_internal.h @@ -7,7 +7,10 @@ #ifndef ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_ #define ZEPHYR_LIB_POSIX_POSIX_INTERNAL_H_ +#include "pthread_sched.h" + #include +#include #include #include @@ -131,4 +134,53 @@ struct k_mutex *to_posix_mutex(pthread_mutex_t *mu); int posix_to_zephyr_priority(int priority, int policy); int zephyr_to_posix_priority(int priority, int *policy); +static inline size_t __get_attr_stacksize(const struct posix_thread_attr *attr) +{ + return attr->stacksize + 1; +} + +static inline bool __attr_is_runnable(const struct posix_thread_attr *attr) +{ + size_t stacksize; + + if (attr == NULL || attr->stack == NULL) { + return false; + } + + stacksize = __get_attr_stacksize(attr); + if (stacksize < PTHREAD_STACK_MIN) { + return false; + } + + /* require a valid scheduler policy */ + if (!valid_posix_policy(attr->schedpolicy)) { + return false; + } + + return true; +} + +static inline bool __attr_is_initialized(const struct posix_thread_attr *attr) +{ + if (IS_ENABLED(CONFIG_DYNAMIC_THREAD)) { + return __attr_is_runnable(attr); + } + + if (attr == NULL || !attr->initialized) { + return false; + } + + return true; +} + +static inline bool is_posix_policy_prio_valid(int priority, int policy) +{ + if (priority >= posix_sched_priority_min(policy) && + priority <= posix_sched_priority_max(policy)) { + return true; + } + + return false; +} + #endif diff --git a/lib/posix/options/pthread.c b/lib/posix/options/pthread.c index 927dead182b4e..008861ac28534 100644 --- a/lib/posix/options/pthread.c +++ b/lib/posix/options/pthread.c @@ -22,11 +22,11 @@ #include #define ZEPHYR_TO_POSIX_PRIORITY(_zprio) \ - (((_zprio) < 0) ? (-1 * ((_zprio) + 1)) : (CONFIG_NUM_PREEMPT_PRIORITIES - (_zprio)-1)) + (((_zprio) < 0) ? (-1 * ((_zprio) + 1)) : (CONFIG_NUM_PREEMPT_PRIORITIES - (_zprio) - 1)) #define POSIX_TO_ZEPHYR_PRIORITY(_prio, _pol) \ (((_pol) == SCHED_FIFO) ? (-1 * ((_prio) + 1)) \ - : (CONFIG_NUM_PREEMPT_PRIORITIES - (_prio)-1)) + : (CONFIG_NUM_PREEMPT_PRIORITIES - (_prio) - 1)) #define DEFAULT_PTHREAD_PRIORITY \ POSIX_TO_ZEPHYR_PRIORITY(K_LOWEST_APPLICATION_THREAD_PRIO, DEFAULT_PTHREAD_POLICY) @@ -43,11 +43,6 @@ LOG_MODULE_REGISTER(pthread, CONFIG_PTHREAD_LOG_LEVEL); #define DYNAMIC_STACK_SIZE 0 #endif -static inline size_t __get_attr_stacksize(const struct posix_thread_attr *attr) -{ - return attr->stacksize + 1; -} - static inline void __set_attr_stacksize(struct posix_thread_attr *attr, size_t stacksize) { attr->stacksize = stacksize - 1; @@ -84,16 +79,17 @@ BUILD_ASSERT(CONFIG_POSIX_PTHREAD_ATTR_STACKSIZE_BITS + CONFIG_POSIX_PTHREAD_ATT static void posix_thread_recycle(void); -__pinned_data -static sys_dlist_t posix_thread_q[] = { +static __pinned_data sys_dlist_t posix_thread_q[] = { SYS_DLIST_STATIC_INIT(&posix_thread_q[POSIX_THREAD_READY_Q]), SYS_DLIST_STATIC_INIT(&posix_thread_q[POSIX_THREAD_RUN_Q]), SYS_DLIST_STATIC_INIT(&posix_thread_q[POSIX_THREAD_DONE_Q]), }; static __pinned_bss struct posix_thread posix_thread_pool[CONFIG_POSIX_THREAD_THREADS_MAX]; +SYS_SEM_DEFINE(pthread_pool_lock, 1, 1); -static SYS_SEM_DEFINE(pthread_pool_lock, 1, 1); +extern struct posix_thread posix_thread_pool[CONFIG_POSIX_THREAD_THREADS_MAX]; +extern struct sys_sem pthread_pool_lock; static int pthread_concurrency; static inline void posix_thread_q_set(struct posix_thread *t, enum posix_thread_qid qid) @@ -240,18 +236,6 @@ void __z_pthread_cleanup_pop(int execute) } } -static bool is_posix_policy_prio_valid(int priority, int policy) -{ - if (priority >= posix_sched_priority_min(policy) && - priority <= posix_sched_priority_max(policy)) { - return true; - } - - LOG_DBG("Invalid priority %d and / or policy %d", priority, policy); - - return false; -} - /* Non-static so that they can be tested in ztest */ int zephyr_to_posix_priority(int z_prio, int *policy) { @@ -278,45 +262,6 @@ int posix_to_zephyr_priority(int priority, int policy) return POSIX_TO_ZEPHYR_PRIORITY(priority, policy); } -static bool __attr_is_runnable(const struct posix_thread_attr *attr) -{ - size_t stacksize; - - if (attr == NULL || attr->stack == NULL) { - LOG_DBG("attr %p is not initialized", attr); - return false; - } - - stacksize = __get_attr_stacksize(attr); - if (stacksize < PTHREAD_STACK_MIN) { - LOG_DBG("attr %p has stacksize %zu is smaller than PTHREAD_STACK_MIN (%zu)", attr, - stacksize, (size_t)PTHREAD_STACK_MIN); - return false; - } - - /* require a valid scheduler policy */ - if (!valid_posix_policy(attr->schedpolicy)) { - LOG_DBG("Invalid scheduler policy %d", attr->schedpolicy); - return false; - } - - return true; -} - -static bool __attr_is_initialized(const struct posix_thread_attr *attr) -{ - if (IS_ENABLED(CONFIG_DYNAMIC_THREAD)) { - return __attr_is_runnable(attr); - } - - if (attr == NULL || !attr->initialized) { - LOG_DBG("attr %p is not initialized", attr); - return false; - } - - return true; -} - /** * @brief Set scheduling parameter attributes in thread attributes object. * @@ -374,88 +319,6 @@ int pthread_attr_setstack(pthread_attr_t *_attr, void *stackaddr, size_t stacksi return 0; } -/** - * @brief Get scope attributes in thread attributes object. - * - * See IEEE 1003.1 - */ -int pthread_attr_getscope(const pthread_attr_t *_attr, int *contentionscope) -{ - struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr) || contentionscope == NULL) { - return EINVAL; - } - *contentionscope = attr->contentionscope; - return 0; -} - -/** - * @brief Set scope attributes in thread attributes object. - * - * See IEEE 1003.1 - */ -int pthread_attr_setscope(pthread_attr_t *_attr, int contentionscope) -{ - struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr)) { - LOG_DBG("attr %p is not initialized", attr); - return EINVAL; - } - if (!(contentionscope == PTHREAD_SCOPE_PROCESS || - contentionscope == PTHREAD_SCOPE_SYSTEM)) { - LOG_DBG("%s contentionscope %d", "Invalid", contentionscope); - return EINVAL; - } - if (contentionscope == PTHREAD_SCOPE_PROCESS) { - /* Zephyr does not yet support processes or process scheduling */ - LOG_DBG("%s contentionscope %d", "Unsupported", contentionscope); - return ENOTSUP; - } - attr->contentionscope = contentionscope; - return 0; -} - -/** - * @brief Get inherit scheduler attributes in thread attributes object. - * - * See IEEE 1003.1 - */ -int pthread_attr_getinheritsched(const pthread_attr_t *_attr, int *inheritsched) -{ - struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr) || inheritsched == NULL) { - return EINVAL; - } - *inheritsched = attr->inheritsched; - return 0; -} - -/** - * @brief Set inherit scheduler attributes in thread attributes object. - * - * See IEEE 1003.1 - */ -int pthread_attr_setinheritsched(pthread_attr_t *_attr, int inheritsched) -{ - struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr)) { - LOG_DBG("attr %p is not initialized", attr); - return EINVAL; - } - - if (inheritsched != PTHREAD_INHERIT_SCHED && inheritsched != PTHREAD_EXPLICIT_SCHED) { - LOG_DBG("Invalid inheritsched %d", inheritsched); - return EINVAL; - } - - attr->inheritsched = inheritsched; - return 0; -} - static void posix_thread_recycle_work_handler(struct k_work *work) { ARG_UNUSED(work); @@ -482,17 +345,12 @@ static void posix_thread_finalize(struct posix_thread *t, void *retval) } SYS_SEM_LOCK(&pthread_key_lock) { - SYS_SLIST_FOR_EACH_NODE_SAFE( - &key_obj->key_data_l, - node_key_data, - node_key_data_s) { + SYS_SLIST_FOR_EACH_NODE_SAFE(&key_obj->key_data_l, node_key_data, + node_key_data_s) { key_data = (struct pthread_key_data *)node_key_data; if (&key_data->thread_data == thread_spec_data) { - sys_slist_remove( - &key_obj->key_data_l, - node_key_data_prev, - node_key_data - ); + sys_slist_remove(&key_obj->key_data_l, + node_key_data_prev, node_key_data); k_free(key_data); break; } @@ -853,81 +711,6 @@ int pthread_cancel(pthread_t pthread) return ret; } -/** - * @brief Set thread scheduling policy and parameters. - * - * See IEEE 1003.1 - */ -int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) -{ - int ret = ESRCH; - int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO; - struct posix_thread *t = NULL; - - if (param == NULL || !valid_posix_policy(policy) || - !is_posix_policy_prio_valid(param->sched_priority, policy)) { - return EINVAL; - } - - SYS_SEM_LOCK(&pthread_pool_lock) { - t = to_posix_thread(pthread); - if (t == NULL) { - ret = ESRCH; - SYS_SEM_LOCK_BREAK; - } - - ret = 0; - new_prio = posix_to_zephyr_priority(param->sched_priority, policy); - } - - if (ret == 0) { - k_thread_priority_set(&t->thread, new_prio); - } - - return ret; -} - -/** - * @brief Set thread scheduling priority. - * - * See IEEE 1003.1 - */ -int pthread_setschedprio(pthread_t thread, int prio) -{ - int ret; - int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO; - struct posix_thread *t = NULL; - int policy = -1; - struct sched_param param; - - ret = pthread_getschedparam(thread, &policy, ¶m); - if (ret != 0) { - return ret; - } - - if (!is_posix_policy_prio_valid(prio, policy)) { - return EINVAL; - } - - ret = ESRCH; - SYS_SEM_LOCK(&pthread_pool_lock) { - t = to_posix_thread(thread); - if (t == NULL) { - ret = ESRCH; - SYS_SEM_LOCK_BREAK; - } - - ret = 0; - new_prio = posix_to_zephyr_priority(prio, policy); - } - - if (ret == 0) { - k_thread_priority_set(&t->thread, new_prio); - } - - return ret; -} - /** * @brief Initialise threads attribute object * @@ -970,40 +753,6 @@ int pthread_attr_init(pthread_attr_t *_attr) return 0; } -/** - * @brief Get thread scheduling policy and parameters - * - * See IEEE 1003.1 - */ -int pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) -{ - int ret = ESRCH; - struct posix_thread *t; - - if (policy == NULL || param == NULL) { - return EINVAL; - } - - SYS_SEM_LOCK(&pthread_pool_lock) { - t = to_posix_thread(pthread); - if (t == NULL) { - ret = ESRCH; - SYS_SEM_LOCK_BREAK; - } - - if (!__attr_is_initialized(&t->attr)) { - ret = ESRCH; - SYS_SEM_LOCK_BREAK; - } - - ret = 0; - param->sched_priority = - zephyr_to_posix_priority(k_thread_priority_get(&t->thread), policy); - } - - return ret; -} - /** * @brief Dynamic package initialization * @@ -1248,40 +997,6 @@ int pthread_attr_setdetachstate(pthread_attr_t *_attr, int detachstate) return 0; } -/** - * @brief Get scheduling policy attribute in Thread attributes. - * - * See IEEE 1003.1 - */ -int pthread_attr_getschedpolicy(const pthread_attr_t *_attr, int *policy) -{ - const struct posix_thread_attr *attr = (const struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr) || (policy == NULL)) { - return EINVAL; - } - - *policy = attr->schedpolicy; - return 0; -} - -/** - * @brief Set scheduling policy attribute in Thread attributes object. - * - * See IEEE 1003.1 - */ -int pthread_attr_setschedpolicy(pthread_attr_t *_attr, int policy) -{ - struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; - - if (!__attr_is_initialized(attr) || !valid_posix_policy(policy)) { - return EINVAL; - } - - attr->schedpolicy = policy; - return 0; -} - /** * @brief Get stack size attribute in thread attributes object. * @@ -1541,8 +1256,7 @@ int pthread_sigmask(int how, const sigset_t *ZRESTRICT set, sigset_t *ZRESTRICT return ret; } -__boot_func -static int posix_thread_pool_init(void) +__boot_func static int posix_thread_pool_init(void) { ARRAY_FOR_EACH_PTR(posix_thread_pool, th) { posix_thread_q_set(th, POSIX_THREAD_READY_Q); diff --git a/lib/posix/options/xsi_realtime_threads.c b/lib/posix/options/xsi_realtime_threads.c new file mode 100644 index 0000000000000..1cb10709b890a --- /dev/null +++ b/lib/posix/options/xsi_realtime_threads.c @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2017 Intel Corporation + * Copyright (c) 2024 Gaetan Perrot + * Copyright (c) 2025 Tenstorrent AI ULC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "posix_clock.h" +#include "posix_internal.h" +#include "pthread_sched.h" + +#include +#include +#include +#include + +extern struct posix_thread posix_thread_pool[CONFIG_POSIX_THREAD_THREADS_MAX]; +extern struct sys_sem pthread_pool_lock; + +LOG_MODULE_REGISTER(xsi_realtime_threads, CONFIG_XSI_REALTIME_THREADS_LOG_LEVEL); + +int pthread_attr_getscope(const pthread_attr_t *_attr, int *contentionscope) +{ + struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; + + if (!__attr_is_initialized(attr) || contentionscope == NULL) { + return EINVAL; + } + *contentionscope = attr->contentionscope; + return 0; +} + +int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope) +{ + struct posix_thread_attr *_attr = (struct posix_thread_attr *)attr; + + if (!__attr_is_initialized(_attr)) { + LOG_DBG("attr %p is not initialized", _attr); + return EINVAL; + } + if (!(contentionscope == PTHREAD_SCOPE_PROCESS || + contentionscope == PTHREAD_SCOPE_SYSTEM)) { + LOG_DBG("%s contentionscope %d", "Invalid", contentionscope); + return EINVAL; + } + if (contentionscope == PTHREAD_SCOPE_PROCESS) { + /* Zephyr does not yet support processes or process scheduling */ + LOG_DBG("%s contentionscope %d", "Unsupported", contentionscope); + return ENOTSUP; + } + _attr->contentionscope = contentionscope; + return 0; +} + +int pthread_attr_getinheritsched(const pthread_attr_t *_attr, int *inheritsched) +{ + struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; + + if (!__attr_is_initialized(attr) || inheritsched == NULL) { + LOG_DBG("attr %p is not initialized", _attr); + return EINVAL; + } + *inheritsched = attr->inheritsched; + return 0; +} + +int pthread_attr_setinheritsched(pthread_attr_t *_attr, int inheritsched) +{ + struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; + + if (!__attr_is_initialized(attr)) { + LOG_DBG("attr %p is not initialized", attr); + return EINVAL; + } + + if ((inheritsched != PTHREAD_INHERIT_SCHED) && (inheritsched != PTHREAD_EXPLICIT_SCHED)) { + LOG_DBG("Invalid inheritsched %d", inheritsched); + return EINVAL; + } + + attr->inheritsched = inheritsched; + return 0; +} + +int pthread_attr_getschedpolicy(const pthread_attr_t *_attr, int *policy) +{ + const struct posix_thread_attr *attr = (const struct posix_thread_attr *)_attr; + + if (!__attr_is_initialized(attr) || (policy == NULL)) { + LOG_DBG("attr %p is not initialized", attr); + return EINVAL; + } + + *policy = attr->schedpolicy; + return 0; +} + +int pthread_attr_setschedpolicy(pthread_attr_t *_attr, int policy) +{ + struct posix_thread_attr *attr = (struct posix_thread_attr *)_attr; + + if (!__attr_is_initialized(attr) || !valid_posix_policy(policy)) { + LOG_DBG("attr %p is not initialized", attr); + return EINVAL; + } + + attr->schedpolicy = policy; + return 0; +} + +int pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) +{ + int ret = ESRCH; + struct posix_thread *t; + + if (policy == NULL || param == NULL) { + return EINVAL; + } + + SYS_SEM_LOCK(&pthread_pool_lock) { + t = to_posix_thread(pthread); + if (t == NULL) { + ret = ESRCH; + SYS_SEM_LOCK_BREAK; + } + + if (!__attr_is_initialized(&t->attr)) { + ret = ESRCH; + SYS_SEM_LOCK_BREAK; + } + + ret = 0; + param->sched_priority = + zephyr_to_posix_priority(k_thread_priority_get(&t->thread), policy); + } + + return ret; +} + +int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex, int *prioceiling) +{ + ARG_UNUSED(mutex); + ARG_UNUSED(prioceiling); + + return ENOSYS; +} + +int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int prioceiling, int *old_ceiling) +{ + ARG_UNUSED(mutex); + ARG_UNUSED(prioceiling); + ARG_UNUSED(old_ceiling); + + return ENOSYS; +} + +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, int *prioceiling) +{ + ARG_UNUSED(attr); + ARG_UNUSED(prioceiling); + + return ENOSYS; +} + +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, int prioceiling) +{ + ARG_UNUSED(attr); + ARG_UNUSED(prioceiling); + + return ENOSYS; +} + +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, int *protocol) +{ + if ((attr == NULL) || (protocol == NULL)) { + return EINVAL; + } + + *protocol = PTHREAD_PRIO_NONE; + return 0; +} + +int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol) +{ + if (attr == NULL) { + return EINVAL; + } + + switch (protocol) { + case PTHREAD_PRIO_NONE: + return 0; + case PTHREAD_PRIO_INHERIT: + return ENOTSUP; + case PTHREAD_PRIO_PROTECT: + return ENOTSUP; + default: + return EINVAL; + } +} + +int pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) +{ + int ret = ESRCH; + int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO; + struct posix_thread *t = NULL; + + if (param == NULL || !valid_posix_policy(policy) || + !is_posix_policy_prio_valid(param->sched_priority, policy)) { + return EINVAL; + } + + SYS_SEM_LOCK(&pthread_pool_lock) { + t = to_posix_thread(pthread); + if (t == NULL) { + ret = ESRCH; + SYS_SEM_LOCK_BREAK; + } + + ret = 0; + new_prio = posix_to_zephyr_priority(param->sched_priority, policy); + } + + if (ret == 0) { + k_thread_priority_set(&t->thread, new_prio); + } + + return ret; +} + +int pthread_setschedprio(pthread_t thread, int prio) +{ + int ret; + int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO; + struct posix_thread *t = NULL; + int policy = -1; + struct sched_param param; + + ret = pthread_getschedparam(thread, &policy, ¶m); + if (ret != 0) { + return ret; + } + + if (!is_posix_policy_prio_valid(prio, policy)) { + return EINVAL; + } + + ret = ESRCH; + SYS_SEM_LOCK(&pthread_pool_lock) { + t = to_posix_thread(thread); + if (t == NULL) { + ret = ESRCH; + SYS_SEM_LOCK_BREAK; + } + + ret = 0; + new_prio = posix_to_zephyr_priority(prio, policy); + } + + if (ret == 0) { + k_thread_priority_set(&t->thread, new_prio); + } + + return ret; +} diff --git a/tests/posix/common/prj.conf b/tests/posix/common/prj.conf index f50d956f8b274..e5300699821ba 100644 --- a/tests/posix/common/prj.conf +++ b/tests/posix/common/prj.conf @@ -3,7 +3,6 @@ CONFIG_POSIX_THREAD_THREADS_MAX=6 CONFIG_ZTEST=y CONFIG_POSIX_SEM_VALUE_MAX=32767 CONFIG_POSIX_MESSAGE_PASSING=y -CONFIG_POSIX_PRIORITY_SCHEDULING=y CONFIG_HEAP_MEM_POOL_SIZE=4096 CONFIG_THREAD_NAME=y CONFIG_DYNAMIC_THREAD=y @@ -26,3 +25,5 @@ CONFIG_XSI_SYSTEM_LOGGING=y # for sched_get_priority_min(), sched_get_priority_max() CONFIG_POSIX_PRIORITY_SCHEDULING=y + +CONFIG_XSI_REALTIME_THREADS=y diff --git a/tests/posix/common/src/mutex.c b/tests/posix/common/src/mutex.c index 20b992620eb8a..52872e33e4946 100644 --- a/tests/posix/common/src/mutex.c +++ b/tests/posix/common/src/mutex.c @@ -88,7 +88,7 @@ static void test_mutex_common(int type, void *(*entry)(void *arg)) ZTEST(mutex, test_mutex_prioceiling_stubs) { -#ifdef CONFIG_POSIX_THREAD_PRIO_PROTECT +#ifdef CONFIG_XSI_REALTIME_THREADS zassert_equal(pthread_mutex_getprioceiling(NULL, NULL), ENOSYS); zassert_equal(pthread_mutex_setprioceiling(NULL, 0, NULL), ENOSYS); zassert_equal(pthread_mutexattr_getprioceiling(NULL, NULL), ENOSYS);