[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] LPC1768/9 LAN8720 FreeRTOS 7.4 LWIP 1.4.1
From: |
Sylvain Rochet |
Subject: |
Re: [lwip-users] LPC1768/9 LAN8720 FreeRTOS 7.4 LWIP 1.4.1 |
Date: |
Fri, 24 May 2013 10:42:38 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
On Fri, May 24, 2013 at 07:35:49AM +0200, Furiantes Furiantes wrote:
> Is tcp_new() thread safe too ? or just netcon. My scenario is that:
No, as said in doc/rawapi.txt :-)
Raw API is *NOT* thread safe: udp_*(), tcp_*(), netif_*(), ...
Netconn API is thread safe: netconn_*()
Socket API is thread safe: lwip_accept(), lwip_bind(), lwip_connect(), ...
NetifAPI is thread safe: netifapi_*()
> - i will call a TCP staff only in seperated threads. Like do_download =
> tcp_new() in one thread and than like listen to some port initialized in
> seperated thread etc. etc.
>
> Is that ok to do or not ? With global access can I access from TCP_1 thread
> to TCP_2 thread like TCP_2 kill TCP_1 thread.
Nah, this is wrong, you *have to* use netconn or socket API.
Also, and this is very important too, Netconn and Socket API are thread
safe against lwIP thread but NOT against themselves, so a UDP or a TCP
PCB must be handled by only one thread. If you want to share a PCB
between threads you can of course add the necessary mutex around Netconn
or Socket calls.
Sylvain
signature.asc
Description: Digital signature