Skip to content
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

posix: implement pthread_attr_getscope() and pthread_attr_setscope() #68450

Conversation

moonlight83340
Copy link
Contributor

This is part of the See #51211 (RFC #51211).

pthread_attr_getscope() and pthread_attr_setscope() are required as part of _POSIX_THREAD_PRIORITY_SCHEDULING Option Group.

For more information, please refer to https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getscope.html

Fixes #66969
Fixes #66967

@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch 3 times, most recently from 17b980b to 2289548 Compare February 2, 2024 09:32
@moonlight83340 moonlight83340 marked this pull request as ready for review February 2, 2024 10:51
@zephyrbot zephyrbot added the area: POSIX POSIX API Library label Feb 2, 2024
@moonlight83340
Copy link
Contributor Author

moonlight83340 commented Feb 2, 2024

I will add tests but would like some reviews on the main part if possible.

@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 2289548 to 6907d41 Compare February 2, 2024 13:29
Copy link
Member

@cfriedt cfriedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Off-by-one error, otherwise it's close. Just a couple more tests, I think

lib/posix/options/posix_internal.h Outdated Show resolved Hide resolved
@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch 3 times, most recently from df8585e to bc2e973 Compare February 3, 2024 14:59
lib/posix/options/posix_internal.h Outdated Show resolved Hide resolved
lib/posix/options/pthread.c Show resolved Hide resolved
tests/posix/common/src/pthread_attr.c Outdated Show resolved Hide resolved
tests/posix/common/src/pthread_attr.c Outdated Show resolved Hide resolved
tests/posix/common/src/pthread_attr.c Outdated Show resolved Hide resolved
@cfriedt
Copy link
Member

cfriedt commented Feb 3, 2024

@moonlight83340 - pretty close. Just some minor changes.

Please be sure to update pthread_attr_init()

@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch 4 times, most recently from 62390d4 to 661fa06 Compare February 4, 2024 05:57
lib/posix/options/pthread.c Outdated Show resolved Hide resolved
@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 661fa06 to 9d98a51 Compare February 4, 2024 14:29
lib/posix/options/pthread.c Outdated Show resolved Hide resolved
Copy link
Member

@cfriedt cfriedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small change requests

  1. make the contentionscope bitfield a bool, and
  2. (potentially?) rework the checks in pthread_attr_setscope()

I found the suggestion a bit more intuitive personally 🤷‍♂️

@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 9d98a51 to 4af97a5 Compare February 5, 2024 00:29
@moonlight83340
Copy link
Contributor Author

Two small change requests

1. make the `contentionscope` bitfield a `bool`, and

2. (potentially?) rework the checks in `pthread_attr_setscope()`

I found the suggestion a bit more intuitive personally 🤷‍♂️

Thank you for your suggestion ! I think #68470 could also be a bool !

@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 4af97a5 to 7eb97f5 Compare February 5, 2024 00:34
@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 7eb97f5 to 9a5e232 Compare February 5, 2024 02:20
Copy link
Collaborator

@ycsin ycsin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably use some optimization

lib/posix/options/pthread.c Outdated Show resolved Hide resolved
lib/posix/options/pthread.c Outdated Show resolved Hide resolved
@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 9a5e232 to 9a16c0e Compare February 5, 2024 04:08
@moonlight83340 moonlight83340 force-pushed the _POSIX_THREAD_PRIORITY_SCHEDULING branch from 9a16c0e to 83e5998 Compare February 6, 2024 02:40
Implement `pthread_attr_setscope()` and `pthread_attr_getscope()`
are required as part of _POSIX_THREAD_PRIORITY_SCHEDULING Option Group.

signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
`pthread_attr_setscope()` and `pthread_attr_getscope()`
are now implemented, mark it so.

signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
Add tests for `pthread_attr_setscope()`
and `pthread_attr_getscope()`

signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
@moonlight83340
Copy link
Contributor Author

@cfriedt I think that PR could use some reviews 😄

@aescolar aescolar merged commit 99f62a7 into zephyrproject-rtos:main Mar 18, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

posix: implement pthread_attr_setscope() posix: implement pthread_attr_getscope()
5 participants