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
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index f9c111e..35d362a 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -273,5 +273,17 @@
return 0;
}
+const char *get_sched_policy_name(SchedPolicy policy)
+{
+ static const char * const strings[SP_CNT] = {
+ [SP_BACKGROUND] = "bg",
+ [SP_FOREGROUND] = "fg",
+ };
+ if ((policy < SP_CNT) && (strings[policy] != NULL))
+ return strings[policy];
+ else
+ return "error";
+}
+
#endif /* HAVE_PTHREADS */
#endif /* HAVE_SCHED_H */