diff options
| author | 2017-03-20 15:03:42 -0700 | |
|---|---|---|
| committer | 2017-03-21 09:27:40 -0700 | |
| commit | 640a104d25db5a46a53c45e7132db577188729cc (patch) | |
| tree | 0fca534117b2794ab3dcb3d437a49141124f6d3d | |
| parent | 211d0cdee08c7fe98ea64d6c5f117859fda8bde0 (diff) | |
Avoid use of pthread_getschedparam (except on the Mac)
Squashed commit of two cherry-picks:
During Thread::DumpState the pthread may have exited.
We have the tid, use that instead.
Test: m -j50 test-art-host -k
Test: adb shell kill -3 `pid system_server`
Bug: 36445592
(cherry picked from commit 08e762782a1e352c329945e0df3f35da7e71ad8a)
Restore broken code for the Mac
Test: m -j48
Bug: 36445592
(cherry picked from commit 4b16f0b860f4d59601706305b2949b98db586a47)
Test: m -j48 && flashall && m -j8 test-art-host
Bug: 36445592
Change-Id: I96d51614f569338d85de0fd59188445df3289dfd
| -rw-r--r-- | runtime/thread.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc index 30a4046d73..008c388229 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -16,6 +16,10 @@ #include "thread.h" +#if !defined(__APPLE__) +#include <sched.h> +#endif + #include <pthread.h> #include <signal.h> #include <sys/resource.h> @@ -1591,8 +1595,21 @@ void Thread::DumpState(std::ostream& os, const Thread* thread, pid_t tid) { if (thread != nullptr) { int policy; sched_param sp; +#if !defined(__APPLE__) + // b/36445592 Don't use pthread_getschedparam since pthread may have exited. + policy = sched_getscheduler(tid); + if (policy == -1) { + PLOG(WARNING) << "sched_getscheduler(" << tid << ")"; + } + int sched_getparam_result = sched_getparam(tid, &sp); + if (sched_getparam_result == -1) { + PLOG(WARNING) << "sched_getparam(" << tid << ", &sp)"; + sp.sched_priority = -1; + } +#else CHECK_PTHREAD_CALL(pthread_getschedparam, (thread->tlsPtr_.pthread_self, &policy, &sp), __FUNCTION__); +#endif os << " sched=" << policy << "/" << sp.sched_priority << " handle=" << reinterpret_cast<void*>(thread->tlsPtr_.pthread_self); } |