[En-Nut-Discussion] killing threads waiting for a connection in NutTcpAccept

Thiago A. Corrêa thiago.correa at gmail.com
Tue Apr 7 15:01:54 CEST 2009


Hi,

On Tue, Apr 7, 2009 at 7:59 AM, José Vallet <jose.vallet at hut.fi> wrote:
>
> The main reason is to save memory. Other than that is simply to not to
> have a thread running that is not necessary, but as you might understand
> this is not a powerful one.
>

  You mentioned earlier that you have more than one thread, perhaps
like the httpd example, where it launches several threads waiting for
connection. You could reduce the number of IDLE threads (and perhaps a
small bit of memory) by launching threads after the NutTcpAccept, so
you have at most 1 IDLE thread, that you must have anyway to keep the
service available.
  Other than that, you could try to do lazy memory allocations. This
includes avoiding static memory allocations, since the compiler will
reserve that chunk at compile time, even when not passing thru that
portion of the code.

Kind Regards,
    Thiago A. Correa



More information about the En-Nut-Discussion mailing list