diff -r -u5 -N -p ecos-v2-alpha-snap-orig/packages/kernel/current/src/sync/mutex.cxx ecos-v2-alpha-snap/packages/kernel/current/src/sync/mutex.cxx --- ecos-v2-alpha-snap-orig/packages/kernel/current/src/sync/mutex.cxx Tue Aug 6 14:57:53 2002 +++ ecos-v2-alpha-snap/packages/kernel/current/src/sync/mutex.cxx Tue Aug 6 14:57:53 2002 @@ -807,12 +807,24 @@ Cyg_Condition_Variable::wait_inner( Cyg_ queue.enqueue( self ); // Avoid calling ASRs during the following unlock. self->set_asr_inhibit(); - // Unlock the scheduler and switch threads - Cyg_Scheduler::unlock_reschedule(); + // The set_timer routine could have waken the thread up again. Do not + // call unlock_reschedule if this thread is still in the running state. + // This seems to happen a lot if this routine was called from select(). + + if (self->get_state() == Cyg_Thread::RUNNING) + { + // Just unlock the scheduler. Do not force a reschedule. + Cyg_Scheduler::unlock(); + } + else + { + // Unlock the scheduler and switch threads + Cyg_Scheduler::unlock_reschedule(); + } // Allow ASRs again self->clear_asr_inhibit(); CYG_ASSERTCLASS( this, "Bad this pointer");