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: pthread: implement pthread_setschedprio #71001

Merged

Conversation

moonlight83340
Copy link
Contributor

I noticed that pthread_setschedprio() was mentioned in the documentation but hasn't actually been implemented yet :
https://github.com/search?q=repo%3Azephyrproject-rtos%2Fzephyr+setschedprio&type=code
image

Therefore, I decided to implement it based on the information provided here: :
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setschedprio.html

@cfriedt
Copy link
Member

cfriedt commented Apr 2, 2024

@moonlight83340 - probably one more test is needed under tests/posix/common

@moonlight83340
Copy link
Contributor Author

@moonlight83340 - probably one more test is needed under tests/posix/common

@moonlight83340
Copy link
Contributor Author

@moonlight83340 - probably one more test is needed under tests/posix/common

Will do that thank you ! (sorry, I close by misstake 😅 )

@moonlight83340 moonlight83340 force-pushed the pthread_setschedprio branch 7 times, most recently from eb2bd1d to 36dc0ce Compare April 3, 2024 10:37
tests/posix/common/src/pthread.c Outdated Show resolved Hide resolved
tests/posix/common/src/pthread.c Outdated Show resolved Hide resolved
tests/posix/common/src/pthread.c Outdated Show resolved Hide resolved
tests/posix/common/src/pthread.c Show resolved Hide resolved
tests/posix/common/src/pthread.c Outdated Show resolved Hide resolved
cfriedt
cfriedt previously approved these changes Apr 3, 2024
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.

LGTM

Comment on lines 879 to 882
int ret = 0;
int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
struct posix_thread *t = NULL;
int policy = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think only new_prio needs to be initialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
int ret = 0;
int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
struct posix_thread *t = NULL;
int policy = 0;
int ret = 0;
int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
struct posix_thread *t = NULL;
int policy;

ret and t should be initialized I think.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ret isn't used before L885 and will be assigned at L885

the initialization of t is probably required here, since it is used in L906

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
int ret = 0;
int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
struct posix_thread *t = NULL;
int policy = 0;
int ret;
int new_prio = K_LOWEST_APPLICATION_THREAD_PRIO;
struct posix_thread *t = NULL;
int policy;

Implement posix pthread_setschedprio()

Signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
Add tests for pthread_setschedprio()

Signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
lib/posix/options/pthread.c Show resolved Hide resolved
lib/posix/options/pthread.c Show resolved Hide resolved
@cfriedt cfriedt merged commit 46f489d into zephyrproject-rtos:main Apr 4, 2024
34 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.

None yet

4 participants