blob: e4730469a7f6d92ff4dbf150cfde645dc8fd6fcd [file] [log] [blame]
Dmitry V. Levinfff2f312014-12-11 19:25:02 +00001#include "defs.h"
2
3#include <sched.h>
4
5#include "xlat/schedulers.h"
Dmitry V. Levin3456bcc2015-07-29 07:59:56 +00006#include "xlat/sched_flags.h"
Dmitry V. Levinfff2f312014-12-11 19:25:02 +00007
Dmitry V. Levina0bd3742015-04-07 01:36:50 +00008SYS_FUNC(sched_getscheduler)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +00009{
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. Levina0bd3742015-04-07 01:36:50 +000020SYS_FUNC(sched_setscheduler)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000021{
Dmitry V. Levin10c408a2015-07-17 16:16:24 +000022 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. Levinfff2f312014-12-11 19:25:02 +000028}
29
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000030SYS_FUNC(sched_getparam)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000031{
Dmitry V. Levinf8bf1d52015-07-17 16:12:22 +000032 if (entering(tcp))
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000033 tprintf("%d, ", (int) tcp->u_arg[0]);
Dmitry V. Levinf8bf1d52015-07-17 16:12:22 +000034 else
35 printnum_int(tcp, tcp->u_arg[1], "%d");
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000036 return 0;
37}
38
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000039SYS_FUNC(sched_setparam)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000040{
Dmitry V. Levin10c408a2015-07-17 16:16:24 +000041 tprintf("%d, ", (int) tcp->u_arg[0]);
42 printnum_int(tcp, tcp->u_arg[1], "%d");
43
44 return RVAL_DECODED;
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000045}
46
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000047SYS_FUNC(sched_get_priority_min)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000048{
Dmitry V. Levin10c408a2015-07-17 16:16:24 +000049 printxval(schedulers, tcp->u_arg[0], "SCHED_???");
50
51 return RVAL_DECODED;
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000052}
53
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000054SYS_FUNC(sched_rr_get_interval)
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000055{
56 if (entering(tcp)) {
Dmitry V. Levinf8bf1d52015-07-17 16:12:22 +000057 tprintf("%d, ", (int) tcp->u_arg[0]);
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000058 } else {
59 if (syserror(tcp))
Dmitry V. Levinf8bf1d52015-07-17 16:12:22 +000060 printaddr(tcp->u_arg[1]);
Dmitry V. Levinfff2f312014-12-11 19:25:02 +000061 else
62 print_timespec(tcp, tcp->u_arg[1]);
63 }
64 return 0;
65}
Dmitry V. Levin3456bcc2015-07-29 07:59:56 +000066
67static void
68print_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
97SYS_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
106SYS_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}