This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: flags question
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Will Wagner <will_wagner at carallon dot com>
- Cc: eCos Discussion <ecos-discuss at ecos dot sourceware dot org>
- Date: Sat, 26 Nov 2005 16:38:41 +0100
- Subject: Re: [ECOS] flags question
- References: <4385DDD1.4030205@carallon.com>
On Thu, Nov 24, 2005 at 03:35:45PM +0000, Will Wagner wrote:
> I have a question about the flags code in the kernel.
>
> I am using the bsd network stack and am running with asserts enabled.
>
> Very occasionally I hit the assert on line 180 of flag.cxx
>
> CYG_ASSERT( 0 == p->value_out, "Thread already awoken?" );
>
> The only code that uses flags is the network alarm thread.
select() also uses flags.
> Has anyone encountered this before? It seems to only occur after the
> scheduler has been locked out for a reasonable period. Presumably there
> is some issue with the two DSR's occurring one after the other without
> the thread getting a chance to run?
I don't think that would cause a problem. The first thing setbits()
does it take the thread off the queue. So if setbits is called twice
in sucession the thread is no longer on the queue for the second call
so it will never run get to the assertion check.
One explanation i can see is if some code is calling setbits from ISR
context. This is illegal. Most of the time it would work, but there is
a race condition. If the interrupt happens after the !(queue.empty())
and before the queue.dequeue() this behavour might happen. It would
also require that dereferencing a null pointer does not throw an
exception, and that (p->allmask == 0) != (p->anymask == 0) happens to
be true for the random junk returned by get_wait_info. You could
check for this by putting in a new assert after the queue.dequeue()
and make sure thread != NULL.
Apart from that the only other idea would be to put a break point in
cyg_assert_fail() and find out the call path and which flags is
causing the problem.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss