chrt: code shrink
function old new delta show_min_max 80 60 -20 packed_usage 26929 26896 -33 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-53) Total: -53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
cd0f6b0c93
commit
922f6f51db
@ -434,7 +434,7 @@ INSERT
|
|||||||
" [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n" \
|
" [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n" \
|
||||||
" [-p N] [-f BYTES] [-c BYTES] PROG ARGS"
|
" [-p N] [-f BYTES] [-c BYTES] PROG ARGS"
|
||||||
#define chpst_full_usage "\n\n" \
|
#define chpst_full_usage "\n\n" \
|
||||||
"Change the process state and run PROG\n" \
|
"Change the process state, run PROG\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
"\n -u USER[:GRP] Set uid and gid" \
|
"\n -u USER[:GRP] Set uid and gid" \
|
||||||
"\n -U USER[:GRP] Set $UID and $GID in environment" \
|
"\n -U USER[:GRP] Set $UID and $GID in environment" \
|
||||||
@ -457,17 +457,17 @@ INSERT
|
|||||||
#define setuidgid_trivial_usage \
|
#define setuidgid_trivial_usage \
|
||||||
"USER PROG ARGS"
|
"USER PROG ARGS"
|
||||||
#define setuidgid_full_usage "\n\n" \
|
#define setuidgid_full_usage "\n\n" \
|
||||||
"Set uid and gid to USER's uid and gid, removing all supplementary\n" \
|
"Set uid and gid to USER's uid and gid, drop supplementary group ids,\n" \
|
||||||
"groups and run PROG"
|
"run PROG"
|
||||||
#define envuidgid_trivial_usage \
|
#define envuidgid_trivial_usage \
|
||||||
"USER PROG ARGS"
|
"USER PROG ARGS"
|
||||||
#define envuidgid_full_usage "\n\n" \
|
#define envuidgid_full_usage "\n\n" \
|
||||||
"Set $UID to USER's uid and $GID to USER's gid and run PROG"
|
"Set $UID to USER's uid and $GID to USER's gid, run PROG"
|
||||||
#define envdir_trivial_usage \
|
#define envdir_trivial_usage \
|
||||||
"DIR PROG ARGS"
|
"DIR PROG ARGS"
|
||||||
#define envdir_full_usage "\n\n" \
|
#define envdir_full_usage "\n\n" \
|
||||||
"Set various environment variables as specified by files\n" \
|
"Set various environment variables as specified by files\n" \
|
||||||
"in the directory dir and run PROG"
|
"in the directory DIR, run PROG"
|
||||||
#define softlimit_trivial_usage \
|
#define softlimit_trivial_usage \
|
||||||
"[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n" \
|
"[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n" \
|
||||||
" [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n" \
|
" [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n" \
|
||||||
@ -538,24 +538,49 @@ INSERT
|
|||||||
#define bbconfig_trivial_usage \
|
#define bbconfig_trivial_usage \
|
||||||
""
|
""
|
||||||
#define bbconfig_full_usage "\n\n" \
|
#define bbconfig_full_usage "\n\n" \
|
||||||
"Print the config file which built busybox"
|
"Print the config file used by busybox build"
|
||||||
|
|
||||||
#define chrt_trivial_usage \
|
#define chrt_trivial_usage \
|
||||||
"[OPTIONS] [PRIO] [PID | PROG ARGS]"
|
"[OPTIONS] [PRIO] [PID | PROG ARGS]"
|
||||||
#define chrt_full_usage "\n\n" \
|
#define chrt_full_usage "\n\n" \
|
||||||
"Manipulate real-time attributes of a process\n" \
|
"Change scheduling priority and class for a process\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
"\n -p Operate on PID" \
|
"\n -p Operate on PID" \
|
||||||
"\n -r Set SCHED_RR scheduling" \
|
"\n -r Set SCHED_RR class" \
|
||||||
"\n -f Set SCHED_FIFO scheduling" \
|
"\n -f Set SCHED_FIFO class" \
|
||||||
"\n -o Set SCHED_OTHER scheduling" \
|
"\n -o Set SCHED_OTHER class" \
|
||||||
"\n -m Show min and max priorities" \
|
"\n -m Show min/max priorities" \
|
||||||
|
|
||||||
#define chrt_example_usage \
|
#define chrt_example_usage \
|
||||||
"$ chrt -r 4 sleep 900; x=$!\n" \
|
"$ chrt -r 4 sleep 900; x=$!\n" \
|
||||||
"$ chrt -f -p 3 $x\n" \
|
"$ chrt -f -p 3 $x\n" \
|
||||||
"You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
|
"You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
|
||||||
|
|
||||||
|
#define nice_trivial_usage \
|
||||||
|
"[-n ADJUST] [PROG ARGS]"
|
||||||
|
#define nice_full_usage "\n\n" \
|
||||||
|
"Change scheduling priority, run PROG\n" \
|
||||||
|
"\nOptions:" \
|
||||||
|
"\n -n ADJUST Adjust priority by ADJUST" \
|
||||||
|
|
||||||
|
#define renice_trivial_usage \
|
||||||
|
"{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID...]"
|
||||||
|
#define renice_full_usage "\n\n" \
|
||||||
|
"Change scheduling priority for a running process\n" \
|
||||||
|
"\nOptions:" \
|
||||||
|
"\n -n Adjust current nice value (smaller is faster)" \
|
||||||
|
"\n -p Process id(s) (default)" \
|
||||||
|
"\n -g Process group id(s)" \
|
||||||
|
"\n -u Process user name(s) and/or id(s)" \
|
||||||
|
|
||||||
|
#define ionice_trivial_usage \
|
||||||
|
"[-c 1-3] [-n 0-7] [-p PID] [PROG]"
|
||||||
|
#define ionice_full_usage "\n\n" \
|
||||||
|
"Change I/O priority and class\n" \
|
||||||
|
"\nOptions:" \
|
||||||
|
"\n -c Class. 1:realtime 2:best-effort 3:idle" \
|
||||||
|
"\n -n Priority" \
|
||||||
|
|
||||||
#define cp_trivial_usage \
|
#define cp_trivial_usage \
|
||||||
"[OPTIONS] SOURCE DEST"
|
"[OPTIONS] SOURCE DEST"
|
||||||
#define cp_full_usage "\n\n" \
|
#define cp_full_usage "\n\n" \
|
||||||
@ -1299,7 +1324,7 @@ INSERT
|
|||||||
#define flock_trivial_usage \
|
#define flock_trivial_usage \
|
||||||
"[-sxun] FD|{FILE [-c] PROG ARGS}"
|
"[-sxun] FD|{FILE [-c] PROG ARGS}"
|
||||||
#define flock_full_usage "\n\n" \
|
#define flock_full_usage "\n\n" \
|
||||||
"[Un]lock file descriptor, or lock FILE and run PROG\n" \
|
"[Un]lock file descriptor, or lock FILE, run PROG\n" \
|
||||||
"\nOptions:" \
|
"\nOptions:" \
|
||||||
"\n -s Shared lock" \
|
"\n -s Shared lock" \
|
||||||
"\n -x Exclusive lock (default)" \
|
"\n -x Exclusive lock (default)" \
|
||||||
@ -2038,14 +2063,6 @@ INSERT
|
|||||||
"\n -Z Set security context" \
|
"\n -Z Set security context" \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define ionice_trivial_usage \
|
|
||||||
"[-c 1-3] [-n 0-7] [-p PID] [PROG]"
|
|
||||||
#define ionice_full_usage "\n\n" \
|
|
||||||
"Change I/O scheduling class and priority\n" \
|
|
||||||
"\nOptions:" \
|
|
||||||
"\n -c Class. 1:realtime 2:best-effort 3:idle" \
|
|
||||||
"\n -n Priority" \
|
|
||||||
|
|
||||||
/* would need to make the " | " optional depending on more than one selected: */
|
/* would need to make the " | " optional depending on more than one selected: */
|
||||||
#define ip_trivial_usage \
|
#define ip_trivial_usage \
|
||||||
"[OPTIONS] {" \
|
"[OPTIONS] {" \
|
||||||
@ -2965,13 +2982,6 @@ INSERT
|
|||||||
"\n -p Display PID/Program name for sockets" \
|
"\n -p Display PID/Program name for sockets" \
|
||||||
)
|
)
|
||||||
|
|
||||||
#define nice_trivial_usage \
|
|
||||||
"[-n ADJUST] [PROG ARGS]"
|
|
||||||
#define nice_full_usage "\n\n" \
|
|
||||||
"Run PROG with modified scheduling priority\n" \
|
|
||||||
"\nOptions:" \
|
|
||||||
"\n -n ADJUST Adjust priority by ADJUST" \
|
|
||||||
|
|
||||||
#define nmeter_trivial_usage \
|
#define nmeter_trivial_usage \
|
||||||
"format_string"
|
"format_string"
|
||||||
#define nmeter_full_usage "\n\n" \
|
#define nmeter_full_usage "\n\n" \
|
||||||
@ -3425,16 +3435,6 @@ INSERT
|
|||||||
"\n" \
|
"\n" \
|
||||||
"\nOther options are silently ignored" \
|
"\nOther options are silently ignored" \
|
||||||
|
|
||||||
#define renice_trivial_usage \
|
|
||||||
"{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID...]"
|
|
||||||
#define renice_full_usage "\n\n" \
|
|
||||||
"Change priority of running processes\n" \
|
|
||||||
"\nOptions:" \
|
|
||||||
"\n -n Adjust current nice value (smaller is faster)" \
|
|
||||||
"\n -p Process id(s) (default)" \
|
|
||||||
"\n -g Process group id(s)" \
|
|
||||||
"\n -u Process user name(s) and/or id(s)" \
|
|
||||||
|
|
||||||
#define scriptreplay_trivial_usage \
|
#define scriptreplay_trivial_usage \
|
||||||
"timingfile [typescript [divisor]]"
|
"timingfile [typescript [divisor]]"
|
||||||
#define scriptreplay_full_usage "\n\n" \
|
#define scriptreplay_full_usage "\n\n" \
|
||||||
|
@ -5,33 +5,35 @@
|
|||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#ifndef _POSIX_PRIORITY_SCHEDULING
|
#ifndef _POSIX_PRIORITY_SCHEDULING
|
||||||
#warning your system may be foobared
|
#warning your system may be foobared
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
int policy;
|
int policy;
|
||||||
char name[12];
|
char name[sizeof("SCHED_OTHER")];
|
||||||
} policies[] = {
|
} policies[] = {
|
||||||
{SCHED_OTHER, "SCHED_OTHER"},
|
{SCHED_OTHER, "SCHED_OTHER"},
|
||||||
{SCHED_FIFO, "SCHED_FIFO"},
|
{SCHED_FIFO, "SCHED_FIFO"},
|
||||||
{SCHED_RR, "SCHED_RR"}
|
{SCHED_RR, "SCHED_RR"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//TODO: add
|
||||||
|
// -b, SCHED_BATCH
|
||||||
|
// -i, SCHED_IDLE
|
||||||
|
|
||||||
static void show_min_max(int pol)
|
static void show_min_max(int pol)
|
||||||
{
|
{
|
||||||
const char *fmt = "%s min/max priority\t: %d/%d\n\0%s not supported?\n";
|
const char *fmt = "%s min/max priority\t: %u/%u\n";
|
||||||
int max, min;
|
int max, min;
|
||||||
|
|
||||||
max = sched_get_priority_max(pol);
|
max = sched_get_priority_max(pol);
|
||||||
min = sched_get_priority_min(pol);
|
min = sched_get_priority_min(pol);
|
||||||
if (max >= 0 && min >= 0)
|
if ((max|min) < 0)
|
||||||
printf(fmt, policies[pol].name, min, max);
|
fmt = "%s not supported\n";
|
||||||
else {
|
printf(fmt, policies[pol].name, min, max);
|
||||||
fmt += 29;
|
|
||||||
printf(fmt, policies[pol].name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OPT_m (1<<0)
|
#define OPT_m (1<<0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user