diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index d0666eaa56..d630bea105 100755 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -132,8 +132,8 @@ do_lock() { // Go to sleep on the condition variable until it's unlocked. - if (thread_cat.is_spam()) { - thread_cat.spam() + if (thread_cat.is_debug()) { + thread_cat.debug() << *this_thread << " blocking on " << *this << " (held by " << *_locking_thread << ")\n"; } @@ -141,8 +141,8 @@ do_lock() { _cvar_impl.wait(); } - if (thread_cat.is_spam()) { - thread_cat.spam() + if (thread_cat.is_debug()) { + thread_cat.debug() << *this_thread << " awake on " << *this << "\n"; } diff --git a/panda/src/pipeline/threadSimpleImpl_no_opt_.cxx b/panda/src/pipeline/threadSimpleImpl_no_opt_.cxx index 3b49a2b4f9..1be1a6859a 100644 --- a/panda/src/pipeline/threadSimpleImpl_no_opt_.cxx +++ b/panda/src/pipeline/threadSimpleImpl_no_opt_.cxx @@ -46,7 +46,13 @@ setup_context_2(ThreadSimpleImpl *self) { // Here we are executing within the thread. v_self->setup_context_3(); + // We shouldn't get here. abort(); + + // Even though this line should never be executed, setting it here + // seems to help the compiler figure out not to optimize away + // v_self. + *v_self = 0; return v_self; } diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index 293ef6da1a..e893a1e10a 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -182,9 +182,8 @@ next_context() { // Mark the current thread's resume point. #ifdef HAVE_PYTHON - // Query the current Python thread state. + // Save the current Python thread state. _current_thread->_python_state = PyThreadState_Swap(NULL); - PyThreadState_Swap(_current_thread->_python_state); #endif // HAVE_PYTHON #ifdef HAVE_UCONTEXT_H @@ -280,9 +279,18 @@ next_context() { _current_thread->_start_time = now; // All right, the thread is ready to roll. Begin. - if (thread_cat.is_spam()) { - thread_cat.spam() - << "Switching to " << *_current_thread->_parent_obj << "\n"; + if (thread_cat.is_debug()) { + size_t blocked_count = 0; + Blocked::const_iterator bi; + for (bi = _blocked.begin(); bi != _blocked.end(); ++bi) { + const FifoThreads &threads = (*bi).second; + blocked_count += threads.size(); + } + + thread_cat.debug() + << "Switching to " << *_current_thread->_parent_obj + << " (" << _ready.size() << " other threads ready, " << blocked_count + << " blocked, " << _sleeping.size() << " sleeping)\n"; } #ifdef HAVE_UCONTEXT_H