diff --git a/libc-test/src/functional/sched_setscheduler.c b/libc-test/src/functional/sched_setscheduler.c new file mode 100644 index 0000000000000000000000000000000000000000..bb12bd20342a4b2a15dceb523a7c905506be24b3 --- /dev/null +++ b/libc-test/src/functional/sched_setscheduler.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include +#include "test.h" + +#define TEST(c) ((!c) ? 1 : (t_error(#c" failed: %s" ,strerror(errno)),0)) + +int main(int argc,char *argv[]) +{ + struct sched_param param; + int maxpri; + + maxpri = sched_get_priority_max(SCHED_FIFO); + if(maxpri == -1) + { + perror("get priority failed"); + return -1; + } + param.sched_priority = maxpri; + TEST(sched_setscheduler(getpid(), SCHED_FIFO, ¶m)); + TEST(!(sched_getscheduler(getpid()) == SCHED_FIFO)); + + return 0; +} + diff --git a/libc-test/src/functional/test_src_functional.gni b/libc-test/src/functional/test_src_functional.gni index d1b5339933f12d80aa1feb3760c123dfeb9588be..405e3a853b95ad15c27a5d7a0e2acfec1056d606 100644 --- a/libc-test/src/functional/test_src_functional.gni +++ b/libc-test/src/functional/test_src_functional.gni @@ -58,6 +58,7 @@ functional_list = [ "strtol", "strtold", "swprintf", + "sched_setscheduler", "tgmath", "time", "tls_align", diff --git a/musl_src.gni b/musl_src.gni index e40299276af4bfbc2e7b5c1ae74d896e990fa7f8..27ab81f381fc0f3360a93ef14069e6c80626ccc0 100644 --- a/musl_src.gni +++ b/musl_src.gni @@ -1838,6 +1838,7 @@ musl_src_porting_file = [ "src/multibyte/wcsnrtombs.c", "src/network/inet_legacy.c", "src/passwd/getspnam_r.c", + "src/sched/sched_setscheduler.c", "src/thread/arm/clone.s", "src/thread/arm/syscall_cp.s", ] diff --git a/porting/linux/user/src/sched/sched_setscheduler.c b/porting/linux/user/src/sched/sched_setscheduler.c new file mode 100644 index 0000000000000000000000000000000000000000..bfedb49bc549cbd3478d0d950b0d9a228001f584 --- /dev/null +++ b/porting/linux/user/src/sched/sched_setscheduler.c @@ -0,0 +1,20 @@ +#include +#include +#include "syscall.h" +#include "pthread_impl.h" + +int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param) +{ + int r; + if (!param) { + r = -EINVAL; + goto exit; + } + + r = __syscall(SYS_sched_setscheduler, pid, sched, param);//, MUSL_TYPE_PROCESS +; +exit: + + + return __syscall_ret(r); +} \ No newline at end of file