summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-03-16 09:43:19 -0700
committerGlenn Kasten <gkasten@google.com>2012-04-20 10:31:50 -0700
commit69bfb1f099164ae7ba44b5d0f7ba7c47cbbafd4d (patch)
tree23bd2952b82061be604ddc9d2945b308c47c42a2 /libcutils
parentc28cbb2c5abe9e93a75185dc7c9e4925a0f9a87a (diff)
downloadsystem_core-69bfb1f099164ae7ba44b5d0f7ba7c47cbbafd4d.zip
system_core-69bfb1f099164ae7ba44b5d0f7ba7c47cbbafd4d.tar.gz
system_core-69bfb1f099164ae7ba44b5d0f7ba7c47cbbafd4d.tar.bz2
Scheduling group cleanup - add comment, SP_DEFAULT
Also tid == 0 maps to gettid() on platforms that support it. This is needed by mediaserver code that was formerly using the old C++ API. Change-Id: I8baaa3e42315c9b924cec26b6da01e7cb69e0078
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/sched_policy.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 35d362a..345532b 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -189,6 +189,11 @@ static int getSchedulerGroup(int tid, char* buf, size_t bufLen)
int get_sched_policy(int tid, SchedPolicy *policy)
{
+#ifdef HAVE_GETTID
+ if (tid == 0) {
+ tid = gettid();
+ }
+#endif
pthread_once(&the_once, __initialize);
if (__sys_supports_schedgroups) {
@@ -219,8 +224,23 @@ int get_sched_policy(int tid, SchedPolicy *policy)
return 0;
}
+/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
+ * Call this any place a SchedPolicy is used as an input parameter.
+ * Returns the possibly re-mapped policy.
+ */
+static inline SchedPolicy _policy(SchedPolicy p)
+{
+ return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
+}
+
int set_sched_policy(int tid, SchedPolicy policy)
{
+#ifdef HAVE_GETTID
+ if (tid == 0) {
+ tid = gettid();
+ }
+#endif
+ policy = _policy(policy);
pthread_once(&the_once, __initialize);
#if POLICY_DEBUG
@@ -275,6 +295,7 @@ int set_sched_policy(int tid, SchedPolicy policy)
const char *get_sched_policy_name(SchedPolicy policy)
{
+ policy = _policy(policy);
static const char * const strings[SP_CNT] = {
[SP_BACKGROUND] = "bg",
[SP_FOREGROUND] = "fg",