Skip to content

posix: implement sched_rr_get_interval() #68316

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/services/portability/posix/option_groups/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ _POSIX_PRIORITY_SCHEDULING
sched_get_priority_min(),yes
sched_getparam(),
sched_getscheduler(),
sched_rr_get_interval(),
sched_rr_get_interval(),yes
sched_setparam(),yes
sched_setscheduler(),yes
sched_yield(),yes
Expand Down
3 changes: 3 additions & 0 deletions include/zephyr/posix/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "posix_types.h"

#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -53,6 +55,7 @@ int sched_getscheduler(pid_t pid);

int sched_setparam(pid_t pid, const struct sched_param *param);
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param);
int sched_rr_get_interval(pid_t pid, struct timespec *interval);

#ifdef __cplusplus
}
Expand Down
10 changes: 10 additions & 0 deletions lib/posix/options/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param)

return -1;
}

int sched_rr_get_interval(pid_t pid, struct timespec *interval)
{
ARG_UNUSED(pid);
ARG_UNUSED(interval);

errno = ENOSYS;

return -1;
}
12 changes: 12 additions & 0 deletions tests/posix/common/src/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,18 @@ ZTEST(pthread, test_sched_setscheduler)
zassert_true((rc == -1 && err == ENOSYS));
}

ZTEST(pthread, test_sched_rr_get_interval)
{
struct timespec interval = {
.tv_sec = 0,
.tv_nsec = 0,
};
int rc = sched_rr_get_interval(0, &interval);
int err = errno;

zassert_true((rc == -1 && err == ENOSYS));
}

ZTEST(pthread, test_pthread_equal)
{
zassert_true(pthread_equal(pthread_self(), pthread_self()));
Expand Down
2 changes: 1 addition & 1 deletion tests/posix/headers/src/sched_h.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ZTEST(posix_headers, test_sched_h)
zassert_not_null(sched_getparam);
zassert_not_null(sched_getscheduler);

/* zassert_not_null(sched_rr_get_interval); */ /* not implemented */
zassert_not_null(sched_rr_get_interval);

zassert_not_null(sched_setparam);
zassert_not_null(sched_setscheduler);
Expand Down