lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Avoiding sys_thread_new


From: Freddie Chopin
Subject: Re: [lwip-users] Avoiding sys_thread_new
Date: Sun, 09 Oct 2016 08:16:22 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]