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" |
| 6 | |
| 7 | int |
| 8 | sys_sched_getscheduler(struct tcb *tcp) |
| 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 | |
| 20 | int |
| 21 | sys_sched_setscheduler(struct tcb *tcp) |
| 22 | { |
| 23 | if (entering(tcp)) { |
| 24 | struct sched_param p; |
| 25 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 26 | printxval(schedulers, tcp->u_arg[1], "SCHED_???"); |
| 27 | if (umove(tcp, tcp->u_arg[2], &p) < 0) |
| 28 | tprintf(", %#lx", tcp->u_arg[2]); |
| 29 | else |
| 30 | tprintf(", { %d }", p.sched_priority); |
| 31 | } |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | int |
| 36 | sys_sched_getparam(struct tcb *tcp) |
| 37 | { |
| 38 | if (entering(tcp)) { |
| 39 | tprintf("%d, ", (int) tcp->u_arg[0]); |
| 40 | } else { |
| 41 | struct sched_param p; |
| 42 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 43 | tprintf("%#lx", tcp->u_arg[1]); |
| 44 | else |
| 45 | tprintf("{ %d }", p.sched_priority); |
| 46 | } |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int |
| 51 | sys_sched_setparam(struct tcb *tcp) |
| 52 | { |
| 53 | if (entering(tcp)) { |
| 54 | struct sched_param p; |
| 55 | if (umove(tcp, tcp->u_arg[1], &p) < 0) |
| 56 | tprintf("%d, %#lx", (int) tcp->u_arg[0], tcp->u_arg[1]); |
| 57 | else |
| 58 | tprintf("%d, { %d }", (int) tcp->u_arg[0], p.sched_priority); |
| 59 | } |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | sys_sched_get_priority_min(struct tcb *tcp) |
| 65 | { |
| 66 | if (entering(tcp)) { |
| 67 | printxval(schedulers, tcp->u_arg[0], "SCHED_???"); |
| 68 | } |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | int |
| 73 | sys_sched_rr_get_interval(struct tcb *tcp) |
| 74 | { |
| 75 | if (entering(tcp)) { |
| 76 | tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]); |
| 77 | } else { |
| 78 | if (syserror(tcp)) |
| 79 | tprintf("%#lx", tcp->u_arg[1]); |
| 80 | else |
| 81 | print_timespec(tcp, tcp->u_arg[1]); |
| 82 | } |
| 83 | return 0; |
| 84 | } |