Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #include <sched.h> |
| 4 | |
| 5 | #include "xlat/schedulers.h" |
Dmitry V. Levin | 3456bcc | 2015-07-29 07:59:56 +0000 | [diff] [blame] | 6 | #include "xlat/sched_flags.h" |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 7 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 8 | SYS_FUNC(sched_getscheduler) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 9 | { |
| 10 | if (entering(tcp)) { |
| 11 | tprintf("%d", (int) tcp->u_arg[0]); |
| 12 | } else if (!syserror(tcp)) { |
| 13 | tcp->auxstr = xlookup(schedulers, tcp->u_rval); |
| 14 | if (tcp->auxstr != NULL) |
| 15 | return RVAL_STR; |
| 16 | } |
| 17 | return 0; |
| 18 | } |
| 19 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 20 | SYS_FUNC(sched_setscheduler) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 21 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 22 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 23 | printxval(schedulers, tcp->u_arg[1], "SCHED_???"); |
| 24 | tprints(", "); |
| 25 | printnum_int(tcp, tcp->u_arg[2], "%d"); |
| 26 | |
| 27 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 30 | SYS_FUNC(sched_getparam) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 31 | { |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 32 | if (entering(tcp)) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 33 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 34 | else |
| 35 | printnum_int(tcp, tcp->u_arg[1], "%d"); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 39 | SYS_FUNC(sched_setparam) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 40 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 41 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 42 | printnum_int(tcp, tcp->u_arg[1], "%d"); |
| 43 | |
| 44 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 47 | SYS_FUNC(sched_get_priority_min) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 48 | { |
Dmitry V. Levin | 10c408a | 2015-07-17 16:16:24 +0000 | [diff] [blame] | 49 | printxval(schedulers, tcp->u_arg[0], "SCHED_???"); |
| 50 | |
| 51 | return RVAL_DECODED; |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 54 | SYS_FUNC(sched_rr_get_interval) |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 55 | { |
| 56 | if (entering(tcp)) { |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 57 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 58 | } else { |
| 59 | if (syserror(tcp)) |
Dmitry V. Levin | f8bf1d5 | 2015-07-17 16:12:22 +0000 | [diff] [blame] | 60 | printaddr(tcp->u_arg[1]); |
Dmitry V. Levin | fff2f31 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 61 | else |
| 62 | print_timespec(tcp, tcp->u_arg[1]); |
| 63 | } |
| 64 | return 0; |
| 65 | } |
Dmitry V. Levin | 3456bcc | 2015-07-29 07:59:56 +0000 | [diff] [blame] | 66 | |
| 67 | static void |
| 68 | print_sched_attr(struct tcb *tcp, const long addr, unsigned int size) |
| 69 | { |
| 70 | struct { |
| 71 | uint32_t size; |
| 72 | uint32_t sched_policy; |
| 73 | uint64_t sched_flags; |
| 74 | uint32_t sched_nice; |
| 75 | uint32_t sched_priority; |
| 76 | uint64_t sched_runtime; |
| 77 | uint64_t sched_deadline; |
| 78 | uint64_t sched_period; |
| 79 | } attr = {}; |
| 80 | |
| 81 | if (size > sizeof(attr)) |
| 82 | size = sizeof(attr); |
| 83 | if (umoven_or_printaddr(tcp, addr, size, &attr)) |
| 84 | return; |
| 85 | |
| 86 | tprintf("{size=%u, sched_policy=", attr.size); |
| 87 | printxval(schedulers, attr.sched_policy, "SCHED_???"); |
| 88 | tprints(", sched_flags="); |
| 89 | printflags(sched_flags, attr.sched_flags, "SCHED_FLAG_???"); |
| 90 | tprintf(", sched_nice=%d", attr.sched_nice); |
| 91 | tprintf(", sched_priority=%u", attr.sched_priority); |
| 92 | tprintf(", sched_runtime=%" PRIu64, attr.sched_runtime); |
| 93 | tprintf(", sched_deadline=%" PRIu64, attr.sched_deadline); |
| 94 | tprintf(", sched_period=%" PRIu64 "}", attr.sched_period); |
| 95 | } |
| 96 | |
| 97 | SYS_FUNC(sched_setattr) |
| 98 | { |
| 99 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 100 | print_sched_attr(tcp, tcp->u_arg[1], 0x100); |
| 101 | tprintf(", %u", (unsigned int) tcp->u_arg[2]); |
| 102 | |
| 103 | return RVAL_DECODED; |
| 104 | } |
| 105 | |
| 106 | SYS_FUNC(sched_getattr) |
| 107 | { |
| 108 | if (entering(tcp)) { |
| 109 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 110 | } else { |
| 111 | print_sched_attr(tcp, tcp->u_arg[1], tcp->u_arg[2]); |
| 112 | tprintf(", %u, %u", |
| 113 | (unsigned int) tcp->u_arg[2], |
| 114 | (unsigned int) tcp->u_arg[3]); |
| 115 | } |
| 116 | |
| 117 | return 0; |
| 118 | } |