diff options
| author | San Mehat <san@google.com> | 2009-10-29 19:52:40 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2009-10-29 19:52:40 -0700 |
| commit | 748cb49e0049e0f504137a4930ec8502affbb03a (patch) | |
| tree | 7ebca39bb75a2b10b9301b9faa784b2d974a49f3 /libcutils | |
| parent | 6dba735a61d4b65594fa0ad7fd15ec09c3c42ce9 (diff) | |
| parent | cc43ee42acc3df89f584c670c4287e25808f23b2 (diff) | |
| download | system_core-748cb49e0049e0f504137a4930ec8502affbb03a.tar.gz system_core-748cb49e0049e0f504137a4930ec8502affbb03a.tar.bz2 system_core-748cb49e0049e0f504137a4930ec8502affbb03a.zip | |
am cc43ee42: am d2e4e46c: cutils: schedpolicy: Add debug code to log sched policy transitions
Merge commit 'cc43ee42acc3df89f584c670c4287e25808f23b2' into eclair-mr2-plus-aosp
* commit 'cc43ee42acc3df89f584c670c4287e25808f23b2':
cutils: schedpolicy: Add debug code to log sched policy transitions
Diffstat (limited to 'libcutils')
| -rw-r--r-- | libcutils/sched_policy.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c index 93fcd4ae9..8357bba33 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c @@ -23,6 +23,9 @@ #include <errno.h> #include <fcntl.h> +#define LOG_TAG "SchedPolicy" +#include "cutils/log.h" + #ifdef HAVE_SCHED_H #include <sched.h> @@ -37,6 +40,8 @@ #define SCHED_BATCH 3 #endif +#define POLICY_DEBUG 1 + static int __sys_supports_schedgroups = -1; static int add_tid_to_cgroup(int tid, const char *grp_name) @@ -155,6 +160,38 @@ int set_sched_policy(int tid, SchedPolicy policy) { initialize(); +#if POLICY_DEBUG + char statfile[64]; + char statline[1024]; + char thread_name[255]; + int fd; + + sprintf(statfile, "/proc/%d/stat", tid); + memset(thread_name, 0, sizeof(thread_name)); + + fd = open(statfile, O_RDONLY); + if (fd >= 0) { + int rc = read(fd, statline, 1023); + close(fd); + statline[rc] = 0; + char *p = statline; + char *q; + + for (p = statline; *p != '('; p++); + p++; + for (q = p; *q != ')'; q++); + + strncpy(thread_name, p, (q-p)); + } + if (policy == SP_BACKGROUND) { + LOGD("vvv tid %d (%s)", tid, thread_name); + } else if (policy == SP_FOREGROUND) { + LOGD("^^^ tid %d (%s)", tid, thread_name); + } else { + LOGD("??? tid %d (%s)", tid, thread_name); + } +#endif + if (__sys_supports_schedgroups) { const char *grp = NULL; |
