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.
--
%SYSTEM-F-ANARCHISM, The operating system has been overthrown
Index: kernel/current/tests/klock.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/tests/klock.c,v
retrieving revision 1.5
diff -u -r1.5 klock.c
--- kernel/current/tests/klock.c 23 May 2002 23:07:00 -0000 1.5
+++ kernel/current/tests/klock.c 10 Jun 2007 21:20:51 -0000
@@ -244,6 +244,7 @@
#else
cyg_mbox_put( mbh, (void *)0xAAAAAAAA );
#endif
+ while( thread0_state < 10 ) cyg_thread_yield();
thread1_state = 10;
#ifdef CYGFUN_KERNEL_THREADS_TIMER
Index: kernel/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/kernel/current/ChangeLog,v
retrieving revision 1.141
diff -u -r1.141 ChangeLog
--- kernel/current/ChangeLog 8 Jan 2007 16:20:13 -0000 1.141
+++ kernel/current/ChangeLog 10 Jun 2007 21:25:36 -0000
@@ -1,3 +1,8 @@
+2007-06-10 Hans Rosenfeld <[EMAIL PROTECTED]>
+
+ * tests/klock.c (entry1): Wait for thread0_state change between
+ mbox get and put.
+
2007-01-07 Andrew Lunn <[EMAIL PROTECTED]>
* src/sync/mbox.cxx (Cyg_Mbox::get): Fix compiler warning with gcc