On nie, 2016-10-09 at 05:08 +0000, Kenny Koller wrote:
> I use C++ and prefer to use a task class that I designed. I do not
> want to allocate these statically. It's not clear to me why the
> network stack would be concerned with creating threads. I understand
> that there is a network thread that is created but I don't want it
> created by sys_thread_new.
> 
> As far as I can tell there is only one Network task that is created.
> How might I rearrange things so that I create that task in my
> application and add it's logic?
> 
> Does anyone foresee any issues if I don't support this call?

Hello again Kenny!

I'm also a huge fan of C++ (C++11 to be exact) - I'm even writing a
C++11 RTOS for microcontrollers ( http://distortos.org/ ) with which
I'm using lwIP right now.

Your assumption that there's only one thread is only partially correct
- in the most common case there in fact is a single thread, but there
may be more - in the lwIP's code base there are actually three calls
to sys_thread_new(): the TCP/IP thread, SNMP agent and SLIP interface.
If you use some code from the "contrib" packages you can get even more
- there are a few dozen calls to this function in the whole package.
That is because more complex "services" or "applications" are
implemented as a single thread.

So if you are pretty sure that in your case only one thread will be
used, then you can allocate it statically and maybe just
use sys_thread_new() to post a semaphore or do whatever is needed to
"start" the thread you created. You can even add some assertion to make
sure this function gets called only once.

Regards,
FCh

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to