[ECOS] assert: "no sleep slots"

Gary Thomas gary@mlbassoc.com
Thu Jul 22 12:13:00 GMT 2004


On Thu, 2004-07-22 at 05:35, Christoph Csebits wrote:
> hi,
> 
> in net/bsd_tcpip/current/src/ecos/synch.c
> 
> there are the following code lines:
> 
>  CYG_ASSERT( i <  CYGPKG_NET_NUM_WAKEUP_EVENTS, "no sleep slots" );
>  
>  // Defensive:
>  if ( i >= CYGPKG_NET_NUM_WAKEUP_EVENTS ) {
>      cyg_scheduler_unlock();
>      return ETIMEDOUT;
>  }
> 
> The things on this:
> 
> 1) The if clause is redundant, because the assert will stop execution anyway.

Only if you have asserts enabled!

> 2) I didn't try to figure out how this works, so my question:
>    Is the assert there because, this must not happen (because of a
>    bug/failure) or is it just here to say "no resources, please adjust
>    your CDL parameters"?
> 
> So, would it be possible to remove the assert and let the if clause 
> return ETIMEDOUT instead?

This does just what it should - if you have asserts on, it will tell you
when you've run out of these resources which is arguably considered an 
error.  If you have no asserts, it at least tries to keep going.

We put the assert in there to trap this condition which we never expect
to see.  In fact, to date it has never happened for anyone AFAIK, so it
is all merely defensive programming (as the comment states)

-- 
Gary Thomas <gary@mlbassoc.com>
MLB Associates


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list