diff options
author | Karel Zak | 2011-05-05 14:23:22 +0200 |
---|---|---|
committer | Karel Zak | 2011-05-05 14:23:38 +0200 |
commit | 503cbbe1d4f2e5113fa709b005780bb376f83656 (patch) | |
tree | 1451d39e2bae88a196ef7f24e168f233979a83bf /schedutils/chrt.c | |
parent | chrt: make threads aware (diff) | |
download | kernel-qcow2-util-linux-503cbbe1d4f2e5113fa709b005780bb376f83656.tar.gz kernel-qcow2-util-linux-503cbbe1d4f2e5113fa709b005780bb376f83656.tar.xz kernel-qcow2-util-linux-503cbbe1d4f2e5113fa709b005780bb376f83656.zip |
chrt: allow to use --all-tasks when retrieve info
master thread:
$ chrt --pid $(pidof firefox)
all threads:
$ chrt --all-tasks --pid $(pidof firefox)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'schedutils/chrt.c')
-rw-r--r-- | schedutils/chrt.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 3669ba6a8..fca347678 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -188,7 +188,8 @@ static void show_min_max(void) int main(int argc, char *argv[]) { - int i, policy = SCHED_RR, priority = 0, verbose = 0, policy_flag = 0, all_tasks = 0; + int i, policy = SCHED_RR, priority = 0, verbose = 0, policy_flag = 0, + all_tasks = 0; struct sched_param sp; pid_t pid = -1; @@ -268,7 +269,18 @@ int main(int argc, char *argv[]) show_usage(EXIT_FAILURE); if ((pid > -1) && (verbose || argc - optind == 1)) { - show_rt_info(pid, FALSE); + if (all_tasks) { + pid_t tid; + struct proc_tasks *ts = proc_open_tasks(pid); + + if (!ts) + err(EXIT_FAILURE, "cannot obtain the list of tasks"); + while (!proc_next_tid(ts, &tid)) + show_rt_info(tid, FALSE); + proc_close_tasks(ts); + } else + show_rt_info(pid, FALSE); + if (argc - optind == 1) return EXIT_SUCCESS; } @@ -296,11 +308,9 @@ int main(int argc, char *argv[]) if (!ts) err(EXIT_FAILURE, "cannot obtain the list of tasks"); - while (!proc_next_tid(ts, &tid)) if (sched_setscheduler(tid, policy, &sp) == -1) err(EXIT_FAILURE, _("failed to set tid %d's policy"), tid); - proc_close_tasks(ts); } else |