From df3773fba068c88ec4ce2d3b65dec57146d2b730 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 16 Jan 2007 15:24:13 +0100 Subject: [PATCH] schedutils: add support for SCHED_BATCH Signed-off-by: Karel Zak --- schedutils/chrt.1 | 7 ++++++- schedutils/chrt.c | 26 +++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/schedutils/chrt.1 b/schedutils/chrt.1 index 6fe81820..9ffc084b 100644 --- a/schedutils/chrt.1 +++ b/schedutils/chrt.1 @@ -36,10 +36,11 @@ chrt \- manipulate real-time attributes of a process .BR chrt (1) sets or retrieves the real-time scheduling attributes of an existing PID or runs COMMAND with the given attributes. Both policy (one of +.BR SCHED_OTHER , .BR SCHED_FIFO , .BR SCHED_RR , or -.BR SCHED_OTHER ) +.BR SCHED_BATCH ) and priority can be set and retrieved. .SH OPTIONS .TP @@ -47,6 +48,10 @@ and priority can be set and retrieved. operate on an existing PID and do not launch a new task .TP +.TP +.B -b, --batch +set scheduling policy to +.BR SCHED_BATCH .TP .B -f, --fifo set scheduling policy to diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 7adff1c4..4c190a82 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -36,6 +36,8 @@ static void show_usage(const char *cmd) fprintf(stderr, "usage: %s [options] [prio] [pid | cmd [args...]]\n", cmd); fprintf(stderr, "manipulate real-time attributes of a process\n"); + fprintf(stderr, " -b, --batch " + "set policy to SCHED_BATCH\n"); fprintf(stderr, " -f, --fifo " "set policy to SCHED_FF\n"); fprintf(stderr, " -p, --pid " @@ -83,6 +85,9 @@ static void show_rt_info(const char *what, pid_t pid) case SCHED_RR: printf("SCHED_RR\n"); break; + case SCHED_BATCH: + printf("SCHED_BATCH\n"); + break; default: printf("unknown\n"); } @@ -101,6 +106,13 @@ static void show_min_max(void) { int max, min; + max = sched_get_priority_max(SCHED_OTHER); + min = sched_get_priority_min(SCHED_OTHER); + if (max >= 0 && min >= 0) + printf("SCHED_OTHER min/max priority\t: %d/%d\n", min, max); + else + printf("SCHED_OTHER not supported?\n"); + max = sched_get_priority_max(SCHED_FIFO); min = sched_get_priority_min(SCHED_FIFO); if (max >= 0 && min >= 0) @@ -115,12 +127,12 @@ static void show_min_max(void) else printf("SCHED_RR not supported?\n"); - max = sched_get_priority_max(SCHED_OTHER); - min = sched_get_priority_min(SCHED_OTHER); + max = sched_get_priority_max(SCHED_BATCH); + min = sched_get_priority_min(SCHED_BATCH); if (max >= 0 && min >= 0) - printf("SCHED_OTHER min/max priority\t: %d/%d\n", min, max); + printf("SCHED_BATCH min/max priority\t: %d/%d\n", min, max); else - printf("SCHED_OTHER not supported?\n"); + printf("SCHED_BATCH not supported?\n"); } int main(int argc, char *argv[]) @@ -130,6 +142,7 @@ int main(int argc, char *argv[]) pid_t pid = 0; struct option longopts[] = { + { "batch", 0, NULL, 'b' }, { "fifo", 0, NULL, 'f' }, { "pid", 0, NULL, 'p' }, { "help", 0, NULL, 'h' }, @@ -141,11 +154,14 @@ int main(int argc, char *argv[]) { NULL, 0, NULL, 0 } }; - while((i = getopt_long(argc, argv, "+fphmorvV", longopts, NULL)) != -1) + while((i = getopt_long(argc, argv, "+bfphmorvV", longopts, NULL)) != -1) { int ret = 1; switch (i) { + case 'b': + policy = SCHED_BATCH; + break; case 'f': policy = SCHED_FIFO; break; -- 2.39.5