summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPovilas Kanapickas2018-01-13 23:27:37 +0200
committerDenys Vlasenko2018-01-23 16:04:48 +0100
commit0f6e4350b3c36b3b4533d0ea910481e28d5f81ab (patch)
tree3394e56ccd93fbbe7bf9d5118f175b5a9234e50a
parent1616fb8aca23fd7ba6b379b0fb38d3327d1e31d1 (diff)
downloadbusybox-0f6e4350b3c36b3b4533d0ea910481e28d5f81ab.zip
busybox-0f6e4350b3c36b3b4533d0ea910481e28d5f81ab.tar.gz
chrt: add support for SCHED_IDLE
Signed-off-by: Povilas Kanapickas <povilas@radix.lt> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/chrt.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/util-linux/chrt.c b/util-linux/chrt.c
index e7abd4f..bbd6e2d 100644
--- a/util-linux/chrt.c
+++ b/util-linux/chrt.c
@@ -17,7 +17,7 @@
//kbuild:lib-$(CONFIG_CHRT) += chrt.o
//usage:#define chrt_trivial_usage
-//usage: "[-prfomb] [PRIO] [PID | PROG ARGS]"
+//usage: "[-prfombi] [PRIO] [PID | PROG ARGS]"
//usage:#define chrt_full_usage "\n\n"
//usage: "Change scheduling priority and class for a process\n"
//usage: "\n -p Operate on PID"
@@ -25,6 +25,7 @@
//usage: "\n -f Set SCHED_FIFO class"
//usage: "\n -o Set SCHED_OTHER class"
//usage: "\n -b Set SCHED_BATCH class"
+//usage: "\n -i Set SCHED_IDLE class"
//usage: "\n -m Show min/max priorities"
//usage:
//usage:#define chrt_example_usage
@@ -42,12 +43,11 @@ static const struct {
{SCHED_OTHER, "SCHED_OTHER"},
{SCHED_FIFO, "SCHED_FIFO"},
{SCHED_RR, "SCHED_RR"},
- {SCHED_BATCH, "SCHED_BATCH"}
+ {SCHED_BATCH, "SCHED_BATCH"},
+ {0 /* unused */, ""},
+ {SCHED_IDLE, "SCHED_IDLE"}
};
-//TODO: add
-// -i, SCHED_IDLE
-
static void show_min_max(int pol)
{
const char *fmt = "%s min/max priority\t: %u/%u\n";
@@ -66,6 +66,7 @@ static void show_min_max(int pol)
#define OPT_f (1<<3)
#define OPT_o (1<<4)
#define OPT_b (1<<5)
+#define OPT_i (1<<6)
int chrt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chrt_main(int argc UNUSED_PARAM, char **argv)
@@ -79,12 +80,13 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
int policy = SCHED_RR;
/* only one policy accepted */
- opt = getopt32(argv, "^+" "mprfob" "\0" "r--fob:f--rob:o--rfb:b--rfo");
+ opt = getopt32(argv, "^+" "mprfobi" "\0" "r--fobi:f--robi:o--rfbi:b--rfoi:i--rfob");
if (opt & OPT_m) { /* print min/max and exit */
show_min_max(SCHED_FIFO);
show_min_max(SCHED_RR);
show_min_max(SCHED_OTHER);
show_min_max(SCHED_BATCH);
+ show_min_max(SCHED_IDLE);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (opt & OPT_r)
@@ -95,6 +97,8 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
policy = SCHED_OTHER;
if (opt & OPT_b)
policy = SCHED_BATCH;
+ if (opt & OPT_i)
+ policy = SCHED_IDLE;
argv += optind;
if (!argv[0])
@@ -138,11 +142,12 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
/* from the manpage of sched_getscheduler:
[...] sched_priority can have a value in the range 0 to 99.
- [...] SCHED_OTHER or SCHED_BATCH must be assigned static priority 0.
+ [...] SCHED_OTHER, SCHED_BATCH or SCHED_IDLE must be assigned static
+ priority 0.
[...] SCHED_FIFO or SCHED_RR can have static priority in 1..99 range.
*/
sp.sched_priority = xstrtou_range(priority, 0,
- (policy != SCHED_OTHER && policy != SCHED_BATCH) ? 1 : 0, 99);
+ (policy != SCHED_OTHER && policy != SCHED_BATCH && policy != SCHED_IDLE) ? 1 : 0, 99);
if (sched_setscheduler(pid, policy, &sp) < 0)
bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid);