This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: kernel/current/tests/klock failure
Andrew Lunn <andrew@lunn.ch> writes:
> On Sun, Jun 10, 2007 at 11:30:39PM +0200, Hans Rosenfeld wrote:
> > While running the klock test, I get the following error message:
> > FAIL:<bad result from cyg_mbox[_timed]_get()> Line: 254, File: /usr/local/share/ecos/packages/kernel/current/tests/klock.c
> >
> > What happens here is that while the first thread is waiting in
> > cyg_mbox_get() for a message the second thread puts a message in the
> > mailbox but immediately gets it back itself because it is not waiting
> > for the first thread to change its state.
> >
> > Putting a message in the mailbox is scheduling the first thread to run,
> > but is not immediately causing a switch into it. I guess that is exactly
> > as it is supposed to be.
> >
> > I attached a simple patch to fix this by inserting a wait for the state
> > change of the first thread.
>
> Hi Hans
>
> This patch looks correct. However i wonder why other people are not
> seeing this failure?
>
> Nick, Jifl, do you ever see this in your test farm?
Looking back, it looks like I fixed this in our sources a few weeks
after making the original patch that switched the mbox implementation.
My fix was slightly different, though similar. I'll check it in if
that is acceptable.
Attached is a copy of what I'm proposing to check in:
Index: kernel/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.141
diff -u -5 -r1.141 ChangeLog
--- kernel/current/ChangeLog 8 Jan 2007 16:20:13 -0000 1.141
+++ kernel/current/ChangeLog 11 Jun 2007 13:02:41 -0000
@@ -1,5 +1,11 @@
+2007-06-11 Nick Garnett <nickg@ecoscentric.com>
+
+ * tests/klock.c (entry0, entry1): Modify mbox part of test to
+ reflect use of plain mbox implementation. The precise ordering of
+ events is slightly different.
+
2007-01-07 Andrew Lunn <andrew.lunn@ascom.ch>
* src/sync/mbox.cxx (Cyg_Mbox::get): Fix compiler warning with gcc
version 4.1.2.
Index: kernel/current/tests/klock.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/tests/klock.c,v
retrieving revision 1.5
diff -u -5 -r1.5 klock.c
--- kernel/current/tests/klock.c 23 May 2002 23:07:00 -0000 1.5
+++ kernel/current/tests/klock.c 11 Jun 2007 13:02:41 -0000
@@ -151,10 +151,12 @@
void *mbret;
mbret = cyg_mbox_get( mbh );
CYG_TEST_CHECK( mbret == (void *)0xAAAAAAAA , "bad result from cyg_mbox_timed_get()");
thread0_state = 10;
+
+ while( thread1_state < 10 ) cyg_thread_yield();
cyg_mbox_put( mbh, (void *)0xBBBBBBBB );
thread0_state = 11;
}
#endif
@@ -244,17 +246,20 @@
#else
cyg_mbox_put( mbh, (void *)0xAAAAAAAA );
#endif
thread1_state = 10;
+ while( thread0_state < 10 ) cyg_thread_yield();
+
#ifdef CYGFUN_KERNEL_THREADS_TIMER
mbret = cyg_mbox_timed_get( mbh, cyg_current_time()+10);
#else
mbret = cyg_mbox_get( mbh );
#endif
+ thread1_state = 11;
CYG_TEST_CHECK( mbret == (void *)0xBBBBBBBB , "bad result from cyg_mbox[_timed]_get()");
- thread1_state = 9;
+ thread1_state = 12;
}
#endif
// --------------------------------------------------
thread1_state = 999;
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com/ The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.