Zephyr's POSIX API is moving toward using the standard nomenclature from IEEE 1003.1-2017 for as much as possible. In particular, we want to have consistent naming between Zephyr's POSIX API Kconfig options and the naming for POSIX Options and Option Groups. The Kconfig option CONFIG_PTHREAD_IPC has been (ab)used for a very long time for a variety of different purposes. However, the standard Option / feature test macro for POSIX Threads is, intuitively _POSIX_THREADS. There is a corresponding sysconf() key named _SC_POSIX_THREADS. Annoyingly, the POSIX Option Group that corresponds to the Option is POSIX_THREADS_BASE, which is a minor inconsistency in the standard. The _POSIX_THREADS Option already includes mutexes, condition variables, and thread-specific storage (keys). So with this change, we also deprecate the redundant Kconfig variables that do not have a corresponding match in the standard. - CONFIG_PTHREAD_IPC - CONFIG_PTHREAD - CONFIG_PTHREAD_COND - CONFIG_PTHREAD_MUTEX - CONFIG_PTHREAD_KEY Additionally, create Kconfig variables for those configurables which we are lacking: - CONFIG_POSIX_THREADS_EXT - CONFIG_POSIX_THREAD_ATTR_STACKSIZE - CONFIG_POSIX_THREAD_ATTR_STACKADDR - CONFIG_POSIX_THREAD_PRIORITY_SCHEDULING - CONFIG_POSIX_THREAD_PRIO_INHERIT - CONFIG_POSIX_THREAD_PRIO_PROTECT - CONFIG_POSIX_THREAD_SAFE_FUNCTIONS Some Kconfig variables were renamed to more properly match the spec: - CONFIG_MAX_PTHREAD_COUNT -> CONFIG_POSIX_THREAD_THREADS_MAX - CONFIG_MAX_PTHREAD_KEY_COUNT -> CONFIG_POSIX_THREAD_KEYS_MAX Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
192 lines
6.7 KiB
Text
192 lines
6.7 KiB
Text
# Copyright (c) 2017 Intel Corporation
|
|
# Copyright (c) 2023 Meta
|
|
# Copyright (c) 2024 Tenstorrent AI ULC
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
menuconfig POSIX_THREADS
|
|
bool "POSIX thread support"
|
|
default y if POSIX_API
|
|
help
|
|
Select 'y' here to enable POSIX threads, mutexes, condition variables, and thread-specific
|
|
storage.
|
|
|
|
For more information please see
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
|
|
|
|
if POSIX_THREADS
|
|
|
|
config POSIX_THREAD_THREADS_MAX
|
|
int "Maximum number of POSIX threads"
|
|
default 5
|
|
help
|
|
Maximum simultaneously active threads in a POSIX application.
|
|
|
|
For more information, see
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
|
|
|
|
config MAX_PTHREAD_MUTEX_COUNT
|
|
int "Maximum number of POSIX mutexes"
|
|
default 5
|
|
help
|
|
Maximum simultaneously active mutexes in a POSIX application.
|
|
|
|
config MAX_PTHREAD_COND_COUNT
|
|
int "Maximum number of POSIX condition variables"
|
|
default 5
|
|
help
|
|
Maximum simultaneously active condition variables in a POSIX application.
|
|
|
|
config POSIX_THREAD_KEYS_MAX
|
|
int "Maximum number of POSIX thread-specific-storage keys"
|
|
default 5
|
|
help
|
|
Maximum simultaneously active thread-specific-storage keys in a POSIX application.
|
|
|
|
For more information, see
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
|
|
|
|
config PTHREAD_RECYCLER_DELAY_MS
|
|
int "Delay for reclaiming dynamic pthread stacks (ms)"
|
|
default 100
|
|
help
|
|
Prior to a POSIX thread terminating via k_thread_abort(), scheduled
|
|
work is added to the system workqueue (SWQ) so that any resources
|
|
allocated by the thread (e.g. thread stack from a pool or the heap)
|
|
can be released back to the system. Because resources are also freed
|
|
on calls to pthread_create() there is no need to worry about resource
|
|
starvation.
|
|
|
|
This option sets the number of milliseconds by which to defer
|
|
scheduled work.
|
|
|
|
Note: this option should be considered temporary and will likely be
|
|
removed once a more synchronous solution is available.
|
|
|
|
config POSIX_THREAD_ATTR_STACKADDR
|
|
bool "Support getting and setting POSIX thread stack addresses"
|
|
default y
|
|
help
|
|
Enable this option to use pthread_attr_getstackaddr() and
|
|
pthread_attr_setstackaddr().
|
|
|
|
This option was removed in IEEE 1003.1-2017 in favour of
|
|
pthread_attr_getstack() and pthread_attr_setstack().
|
|
|
|
For more information, please see
|
|
https://pubs.opengroup.org/onlinepubs/009696799/functions/pthread_attr_getstackaddr.html
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_08
|
|
|
|
config POSIX_THREAD_ATTR_STACKSIZE
|
|
bool "Support getting and setting POSIX thread stack sizes"
|
|
default y
|
|
help
|
|
Enable this option to use pthread_attr_getstacksize() or
|
|
pthread_attr_setstacksize().
|
|
|
|
For more information, please see
|
|
https://pubs.opengroup.org/onlinepubs/009696699/functions/pthread_attr_getstacksize.html
|
|
|
|
config POSIX_THREADS_EXT
|
|
bool "Extended POSIX thread support"
|
|
default y
|
|
help
|
|
Enable this option to use pthread_attr_getguardsize(), pthread_attr_setguardsize(),
|
|
pthread_mutexattr_gettype(), or pthread_mutexattr_settype().
|
|
|
|
For more information, please see
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
|
|
|
|
config POSIX_THREAD_PRIORITY_SCHEDULING
|
|
bool "Run POSIX threads with different priorities and schedulers"
|
|
default y
|
|
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
|
|
|
|
config POSIX_PTHREAD_ATTR_STACKSIZE_BITS
|
|
int "Significant bits for pthread_attr_t stacksize"
|
|
range 8 31
|
|
default 23
|
|
help
|
|
This value plays a part in determining the maximum supported
|
|
pthread_attr_t stacksize. Valid stacksizes are in the range
|
|
[1, N], where N = 1 << M, and M is this configuration value.
|
|
|
|
config POSIX_PTHREAD_ATTR_GUARDSIZE_BITS
|
|
int "Significant bits for pthread_attr_t guardsize"
|
|
range 1 31
|
|
default 9
|
|
help
|
|
This value plays a part in determining the maximum supported
|
|
pthread_attr_t guardsize. Valid guardsizes are in the range
|
|
[0, N-1], where N = 1 << M, and M is this configuration value.
|
|
|
|
Actual guardsize values may be rounded-up.
|
|
|
|
config POSIX_PTHREAD_ATTR_GUARDSIZE_DEFAULT
|
|
int "Default size of stack guard area"
|
|
default 0
|
|
help
|
|
This is the default amount of space to reserve at the overflow end of a
|
|
pthread stack. Since Zephyr already supports both software-based stack
|
|
protection (canaries) and hardware-based stack protection (MMU or MPU),
|
|
this is set to 0 by default. However, a conforming application would be
|
|
required to set this to PAGESIZE. Eventually, this option might
|
|
facilitate a more dynamic approach to guard areas (via software or
|
|
hardware) but for now it simply increases the size of thread stacks.
|
|
|
|
config POSIX_THREAD_PRIO_INHERIT
|
|
bool "POSIX mutex priority inheritance"
|
|
default y
|
|
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
|
|
|
|
config POSIX_THREAD_PRIO_PROTECT
|
|
bool "POSIX mutex priority protection"
|
|
default y
|
|
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
|
|
|
|
config POSIX_THREAD_SAFE_FUNCTIONS
|
|
bool "POSIX thread-safe functions"
|
|
default y
|
|
help
|
|
Select 'y' here to enable POSIX thread-safe functions including asctime_r(), ctime_r(),
|
|
flockfile(), ftrylockfile(), funlockfile(), getc_unlocked(), getchar_unlocked(),
|
|
getgrgid_r(), getgrnam_r(), getpwnam_r(), getpwuid_r(), gmtime_r(), localtime_r(),
|
|
putc_unlocked(), putchar_unlocked(), rand_r(), readdir_r(), strerror_r(), and strtok_r().
|
|
|
|
For more information, please see
|
|
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap02.html#tag_22_02_09_07
|
|
|
|
module = PTHREAD
|
|
module-str = POSIX thread
|
|
source "subsys/logging/Kconfig.template.log_config"
|
|
|
|
module = PTHREAD_MUTEX
|
|
module-str = POSIX mutex
|
|
source "subsys/logging/Kconfig.template.log_config"
|
|
|
|
module = PTHREAD_COND
|
|
module-str = POSIX condition variable
|
|
source "subsys/logging/Kconfig.template.log_config"
|
|
|
|
module = PTHREAD_KEY
|
|
module-str = POSIX thread-specific data
|
|
source "subsys/logging/Kconfig.template.log_config"
|
|
|
|
endif # POSIX_THREADS
|