diff options
| author | Glenn Kasten <gkasten@google.com> | 2012-03-05 16:14:39 -0800 |
|---|---|---|
| committer | Glenn Kasten <gkasten@google.com> | 2012-03-15 15:10:45 -0700 |
| commit | 86c7cc81891a69ace7044de667b0624c284ee82b (patch) | |
| tree | 6fff9f3e763724ee70181b6559e0a76b1ec21a03 /toolbox/top.c | |
| parent | 019524a60e979053b8b8ffef61eae162de522257 (diff) | |
| download | system_core-86c7cc81891a69ace7044de667b0624c284ee82b.tar.gz system_core-86c7cc81891a69ace7044de667b0624c284ee82b.tar.bz2 system_core-86c7cc81891a69ace7044de667b0624c284ee82b.zip | |
Add get_sched_policy_name() and use in ps and top
This will make it easier to add additional policies (cgroups) if needed.
Also added comments to the sched_policy APIs.
Change-Id: I33ce1cc4deae10983241f7391294b7a512d2c47c
Diffstat (limited to 'toolbox/top.c')
| -rw-r--r-- | toolbox/top.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/toolbox/top.c b/toolbox/top.c index 999c8e12..7642522d 100644 --- a/toolbox/top.c +++ b/toolbox/top.c @@ -48,6 +48,7 @@ struct cpu_info { #define PROC_NAME_LEN 64 #define THREAD_NAME_LEN 32 +#define POLICY_NAME_LEN 4 struct proc_info { struct proc_info *next; @@ -67,7 +68,7 @@ struct proc_info { long rss; int prs; int num_threads; - char policy[32]; + char policy[POLICY_NAME_LEN]; }; struct proc_list { @@ -381,14 +382,10 @@ static int read_cmdline(char *filename, struct proc_info *proc) { static void read_policy(int pid, struct proc_info *proc) { SchedPolicy p; if (get_sched_policy(pid, &p) < 0) - strcpy(proc->policy, "unk"); + strlcpy(proc->policy, "unk", POLICY_NAME_LEN); else { - if (p == SP_BACKGROUND) - strcpy(proc->policy, "bg"); - else if (p == SP_FOREGROUND) - strcpy(proc->policy, "fg"); - else - strcpy(proc->policy, "er"); + strlcpy(proc->policy, get_sched_policy_name(p), POLICY_NAME_LEN); + proc->policy[2] = '\0'; } } |
