[ECOS] ecos + lwip

Simon Kallweit simon.kallweit@intefo.ch
Tue Sep 1 15:32:00 GMT 2009


Mandeep Sandhu wrote:
> On Tue, Sep 1, 2009 at 7:08 PM, Simon Kallweit<simon.kallweit@intefo.ch> wrote:
>> Mandeep Sandhu wrote:
>> sys_thread_new() will use preallocated memory for the stack, while
>> cyg_lwip_thread_new() will take the stack as an argument. Therefore by
>> default you should use cyg_lwip_thread_new(). When using sys_thread_new()
>> the ecos should fail when all preallocated memory is used.
> 
> But sys_thread_new() also takes stacksize as an argument. It passes
> the same value
> to cyg_lwip_thread_new() after validating it. So I guess it should be ok.

Yes, sys_thread_new() takes a stacksize argument, but no pointer to the 
actual memory. The current code uses a statically allocated buffer for 
all lwip's internal stacks, but it is not large enough to hold 
additional stacks from users, hence the cyg_lwip_thread_new() API where 
the user can provide a pointer to the actual stack memory to be used.

Your application should FAIL when using sys_thread_new() with the 
following message:

"Not enough memory to allocate the thread's stack. You may want to use 
cyg_lwip_thread_new() instead of sys_thread_new() so you can provide 
external stack memory."

This message should pop up unless you have asserts disabled?!?

Maybe I should add an option in the CDL to enlarge the statically 
allocated internal stack memory so users could allocate threads with 
sys_thread_new(). But I don't personally like it, as you may waste 
memory. cyg_lwip_thread_new() does solve this problem by forcing you to 
allocate the stack memory yourself.

Please try to use cyg_lwip_thread_new() and tell me if that works.

Simon

-- 
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