From 00e6da98f31cce57fbbd768fc78649442d7ba494 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 21 May 2017 13:23:34 -0500 Subject: Promote chrt --- toys/other/chrt.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ toys/pending/chrt.c | 81 ----------------------------------------------------- 2 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 toys/other/chrt.c delete mode 100644 toys/pending/chrt.c (limited to 'toys') diff --git a/toys/other/chrt.c b/toys/other/chrt.c new file mode 100644 index 00000000..aa0a140d --- /dev/null +++ b/toys/other/chrt.c @@ -0,0 +1,81 @@ +/* chrt.c - Get/set real-time (scheduling) attributes + * + * Copyright 2016 The Android Open Source Project + * + * Note: -ibrfo flags sorted to match SCHED positions for highest_bit() + +USE_CHRT(NEWTOY(chrt, "^mp#<0iRbrfo[!ibrfo]", TOYFLAG_USR|TOYFLAG_SBIN)) + +config CHRT + bool "chrt" + default y + help + usage: chrt [-Rmofrbi] {-p PID [PRIORITY] | [PRIORITY COMMAND...]} + + Get/set a process' real-time scheduling policy and priority. + + -p Set/query given pid (instead of running COMMAND) + -R Set SCHED_RESET_ON_FORK + -m Show min/max priorities available + + Set policy (default -r): + + -o SCHED_OTHER -f SCHED_FIFO -r SCHED_RR + -b SCHED_BATCH -i SCHED_IDLE +*/ + +#define FOR_chrt +#include "toys.h" + +GLOBALS( + long pid; +) + +char *polnames[] = { + "SCHED_OTHER", "SCHED_FIFO", "SCHED_RR", "SCHED_BATCH", 0, "SCHED_IDLE", + "SCHED_DEADLINE" +}; + +void chrt_main(void) +{ + int pol, pri; + + // Show min/maxes? + if (toys.optflags&FLAG_m) { + for (pol = 0; pol