This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: kernel/current/tests/klock failure
- From: Gary Thomas <gary at mlbassoc dot com>
- To: Hans Rosenfeld <rosenfeld at grumpf dot hope-2000 dot org>
- Cc: ecos-patches at ecos dot sourceware dot org
- Date: Mon, 11 Jun 2007 06:20:27 -0600
- Subject: Re: kernel/current/tests/klock failure
- References: <20070610213039.GA26064@grumpf.hope-2000.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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.
>
>
>
> ----------------------------------------------------------------------
>
> 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;
Why the [seemingly arbitrary] 10 times to yield? Shouldn't one be
sufficient?
>
> #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 <rosenfeld@grumpf.hope-2000.org>
> +
> + * tests/klock.c (entry1): Wait for thread0_state change between
> + mbox get and put.
> +
> 2007-01-07 Andrew Lunn <andrew.lunn@ascom.ch>
>
> * src/sync/mbox.cxx (Cyg_Mbox::get): Fix compiler warning with gcc
- --
- ------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
- ------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGbT4JmaKbSsQGV8ARAjvOAKCKLYfy4TfKVCGl5iDADZ+N53+WrACgq0mh
M6MuwMkSmQANG258O6Rk3p0=
=rTRT
-----END PGP SIGNATURE-----