Fei Jie | ea5c7b5 | 2016-03-10 17:12:24 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #if defined __NR_sched_getparam && defined __NR_sched_setparam |
| 5 | |
| 6 | # include <errno.h> |
| 7 | # include <sched.h> |
| 8 | # include <stdio.h> |
| 9 | # include <unistd.h> |
| 10 | |
| 11 | int |
| 12 | main(void) |
| 13 | { |
| 14 | struct sched_param *const param = tail_alloc(sizeof(struct sched_param)); |
| 15 | int rc = syscall(__NR_sched_getparam, 0, param); |
| 16 | printf("sched_getparam(0, [%d]) = %d\n", |
| 17 | param->sched_priority, rc); |
| 18 | |
| 19 | param->sched_priority = -1; |
| 20 | rc = syscall(__NR_sched_setparam, 0, param); |
| 21 | printf("sched_setparam(0, [%d]) = %d %s (%m)\n", |
| 22 | param->sched_priority, rc, |
| 23 | errno == EPERM ? "EPERM" : "EINVAL"); |
| 24 | |
| 25 | puts("+++ exited with 0 +++"); |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | #else |
| 30 | |
| 31 | SKIP_MAIN_UNDEFINED("__NR_sched_getparam && __NR_sched_setparam") |
| 32 | |
| 33 | #endif |