243 static int __pthread_start(void* arg) { 244 pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(arg); 245 246 // Wait for our creating thread to release us. This lets it have time to 247 // notify gdb about this thread before we start doing anything. 248 // This also provides the memory barrier needed to ensure that all memory 249 // accesses previously made by the creating thread are visible to us. 250 thread->startup_handshake_lock.lock(); 251 252 __init_alternate_signal_stack(thread); 253 254 void* result = thread->start_routine(thread->start_routine_arg); 255 pthread_exit(result); 256 257 return 0; 258 }
#03 pc 0000c1bf /system/lib/libutils.so (android::Thread::_threadLoop(void*)+286)
711 int Thread::_threadLoop(void* user) 712 { 713 Thread* const self = static_cast<Thread*>(user); 714 715 sp<Thread> strong(self->mHoldSelf); 716 wp<Thread> weak(strong); 717 self->mHoldSelf.clear(); 718 719 #if defined(__ANDROID__) 720 // this is very useful for debugging with gdb 721 self->mTid = gettid(); 722 #endif 723 724 bool first = true; 725 726 do { 727 bool result; 728 if (first) { 729 first = false; 730 self->mStatus = self->readyToRun(); 731 result = (self->mStatus == NO_ERROR); 732 733 if (result && !self->exitPending()) { 734 // Binder threads (and maybe others) rely on threadLoop 735 // running at least once after a successful ::readyToRun() 736 // (unless, of course, the thread has already been asked to exit 737 // at that point). 738 // This is because threads are essentially used like this: 739 // (new ThreadSubclass())->run(); 740 // The caller therefore does not retain a strong reference to 741 // the thread and the thread would simply disappear after the 742 // successful ::readyToRun() call instead of entering the 743 // threadLoop at least once. 744 result = self->threadLoop(); 745 } 746 } else { 747 result = self->threadLoop(); 748 } 749 750 // establish a scope for mLock 751 { 752 Mutex::Autolock _l(self->mLock); 753 if (result == false || self->mExitPending) { 754 self->mExitPending = true; 755 self->mRunning = false; 756 // clear thread ID so that requestExitAndWait() does not exit if 757 // called by a new thread using the same thread ID as this one. 758 self->mThread = thread_id_t(-1); 759 // note that interested observers blocked in requestExitAndWait are 760 // awoken by broadcast, but blocked on mLock until break exits scope 761 self->mThreadExitedCondition.broadcast(); 762 break; 763 } 764 } 765 766 // Release our strong reference, to let a chance to the thread 767 // to die a peaceful death. 768 strong.clear(); 769 // And immediately, re-acquire a strong reference for the next loop 770 strong = weak.promote(); 771 } while(strong != 0); 772 773 return 0; 774 }
#02 pc 0000e307 /system/lib/libmedia_helper.so (android::TimeCheck::TimeCheckThread::threadLoop()+270)
01-01 08:00:29.697 3148 3223 I ServiceManager: Waiting for service media.audio_policy... 01-01 08:00:30.699 3148 3223 I ServiceManager: Waiting for service media.audio_policy... 01-01 08:00:31.709 3148 3223 I ServiceManager: Waiting for service media.audio_policy... 01-01 08:00:32.712 3148 3223 I ServiceManager: Waiting for service media.audio_policy... 01-01 08:00:33.717 3148 3223 I ServiceManager: Waiting for service media.audio_policy... 01-01 08:00:33.783 3148 3365 F : TimeCheck timeout for IAudioFlinger 01-01 08:00:33.817 3148 3223 W ServiceManager: Service media.audio_policy didn't start. Returning NULL 01-01 08:00:33.817 3148 3223 W AudioSystem: AudioPolicyService not published, waiting..