lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] When and how often are mtx/sem/mox new() and free() cal


From: address@hidden
Subject: Re: [lwip-users] When and how often are mtx/sem/mox new() and free() called?
Date: Thu, 11 Nov 2021 08:01:44 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

Am 10.11.2021 um 22:45 schrieb Grant Edwards:
Another porting question, I'm afraid.

In deciding how to implement new/free operations for mailboxes,
semaphores, and mutexes, it would be helpful if I had some idea of
when and how often they are called.

Are execution times for these functions going to noticeably affect
performance of things like a small web server and MQTT client?

Or should I do things using a simple and obviously correct method.

I tend toward the latter unless warned beforehand that something is in
a time-critical path.

- allocation of mutexes is only done when initializing lwIP
- allocation/deallocation of mboxes is done when initializing lwIP *and*
when creating/closing a socket
- allocation/deallocation of semaphores is done when creating/closing a
socket and when calling sys_msleep()

BUT: allocation/deallocation of sempahores is also done:
- for many API calls (from an application thread into the tcpip-thread)
or tcpip_calback when LWIP_TCPIP_CORE_LOCKING==0
- for select and for DNS API calls (like gethostbyname etc) when
LWIP_NETCONN_SEM_PER_THREAD==0

Note that LWIP_NETCONN_SEM_PER_THREAD==1 needs thread-local storage
support. Also, sys_msleep() isn't really broadly used but could probably
be somehow converted to use LWIP_NETCONN_SEM_PER_THREAD, too.

Overall, this doesn't look time-critical to me (unless you are making
heavy use of netconn/sockets and explicitly change
LWIP_TCPIP_CORE_LOCKING from its default setting 1 to 0).

Regards,
Simon



reply via email to

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