public inbox for ecos-maintainers@sourceware.org
 help / color / mirror / Atom feed
* timed condition variable patch
@ 2002-08-06 15:13 Wade Jensen
  0 siblings, 0 replies; only message in thread
From: Wade Jensen @ 2002-08-06 15:13 UTC (permalink / raw)
  To: ecos-patches, ecos-maintainers

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

Hello,

There is a very rare condition in Cyg_Condition_Variable::wait_inner(
Cyg_Mutex *mx, cyg_tick_count timeout ) that causes the "Unnecessary call to
unlock_inner()" assertion to fail.

Here is a patch for this problem.  It is based off of the 2.0 snapshot
source.

Thanks,
Wade

[-- Attachment #2: patch.unlock_inner_assertion --]
[-- Type: application/octet-stream, Size: 1271 bytes --]

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");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-06 22:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-06 15:13 timed condition variable patch Wade Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).