-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[WIP] lib: posix: auto allocate pthread stack if needed #26474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,36 @@ config SEM_VALUE_MAX | |
help | ||
Maximum semaphore count in POSIX compliant Application. | ||
|
||
config PTHREAD_DYNAMIC_STACK | ||
bool "Support for dynamic stacks" | ||
default y | ||
help | ||
POSIX 1003.1 allows a NULL pthread_attr_t* to be passed to | ||
pthread_create(3). However, Zephyr has traditionally required | ||
that the caller statically allocate a stack and pass it in via the | ||
pthread_attr_t*. With this option selected, NULL will be permitted | ||
and a suitable stack will be automatically allocated and assigned, | ||
inheriting permissions from the calling thread. | ||
|
||
if PTHREAD_DYNAMIC_STACK | ||
config PTHREAD_DYNAMIC_STACK_SIZE | ||
int "Dynamic pthread stack size (in bytes)" | ||
default 2048 | ||
range 1 4096 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that "1" is realistic lower bound here. The standard (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html) says:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And yeah, why 4096 is upper bound? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pfalcon - the only reference I have in Zephyr for There is Correct me if I'm wrong, but it would seem that Kconfig does not allow us to set a @andrewboie - any ideas? |
||
help | ||
Fix the size of dynamically-allocated stacks to be this many bytes. | ||
|
||
# May be zero in order to later facilitate exclusively heap-allocated stacks | ||
# API is currently in development | ||
config PTHREAD_DYNAMIC_STACK_RESERVED_COUNT | ||
int "The number of statically allocated dynamically assignable stacks" | ||
cfriedt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default 0 | ||
range 0 32 | ||
help | ||
Statically allocate this many stacks at compile-time. | ||
|
||
endif # PTHREAD_DYNAMIC_STACK | ||
|
||
endif # PTHREAD_IPC | ||
|
||
config POSIX_CLOCK | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please spell it fully: "Support for dynamic thread stacks"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, @pfalcon, I don't even think there should be a Kconfig for this. It's basically synonymous with "are we allowed to pass a NULL attr?" The spec explicitly says "yes" here. Maybe removing this would make it easier to solve the static / dynamic wording as well?
I guess the way you're leaning is that dynamic <=> heap-allocated, while static <=> statically allocated?
It would be nice to get @andrewboie 's input as well for naming.