lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Issue in multithread system


From: gkn
Subject: [lwip-users] Issue in multithread system
Date: Tue, 18 Sep 2012 03:00:48 -0700 (PDT)

Hi,

I am using LWIP1.3.2 with MicroC OS. There are 2 threads in my system. 
high priority tcpip thread and low priority application thread. MAC ISR is
enabled to detect incoming packet, DMA the received packet to SRAM and send
a message to tcpip thread.

application thread functionality:
1. look for connection availability in a socket by calling lwip_select()
2. Accept the connection by calling lwip_accept()
3. receive the data by calling lwip_recv()
4. Decode the arrived data and prepare response
5. send response by calling lwip_send()
6. terminate the connection by calling lwip_close()  

lwip configuration parameters:

#define SYS_LIGHTWEIGHT_PROT            1
#define NO_SYS                          0
#define MEMCPY(dst,src,len)             memcpy(dst,src,len)
#define SMEMCPY(dst,src,len)            memcpy(dst,src,len)
#define MEM_LIBC_MALLOC                 0
#define MEMP_MEM_MALLOC                 0
#define MEM_ALIGNMENT                   4
#define MEM_SIZE                        32768
#define MEMP_OVERFLOW_CHECK             0
#define MEMP_SANITY_CHECK               0
#define MEM_USE_POOLS                   0
#define MEM_USE_POOLS_TRY_BIGGER_POOL   0
#define MEMP_USE_CUSTOM_POOLS           0
#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0
#define MEMP_NUM_PBUF                   32
#define MEMP_NUM_RAW_PCB                4
#define MEMP_NUM_UDP_PCB                8
#define MEMP_NUM_TCP_PCB                8
#define MEMP_NUM_TCP_PCB_LISTEN         2
#define MEMP_NUM_TCP_SEG                90
#define MEMP_NUM_REASSDATA              5
#define MEMP_NUM_ARP_QUEUE              30
#define MEMP_NUM_IGMP_GROUP             8
#define MEMP_NUM_SYS_TIMEOUT            5
#define MEMP_NUM_NETBUF                 32
#define MEMP_NUM_NETCONN                4
#define MEMP_NUM_TCPIP_MSG_API          LWIP_Q_SIZE
#define MEMP_NUM_TCPIP_MSG_INPKT        LWIP_Q_SIZE
#define PBUF_POOL_SIZE                  16
#define LWIP_ARP                        1
#define ARP_TABLE_SIZE                  10
#define ARP_QUEUEING                    1
#define ETHARP_TRUST_IP_MAC             1
#define ETHARP_SUPPORT_VLAN             0
#define IP_FORWARD                      0
#define IP_OPTIONS_ALLOWED              1
#define IP_REASSEMBLY                   1
#define IP_FRAG                         1
#define IP_REASS_MAXAGE                 3
#define IP_REASS_MAX_PBUFS              10
#define IP_FRAG_USES_STATIC_BUF         1
#define IP_FRAG_MAX_MTU                 1500
#define IP_DEFAULT_TTL                  255
#define IP_SOF_BROADCAST                0
#define IP_SOF_BROADCAST_RECV           0
#define LWIP_ICMP                       1
#define ICMP_TTL                       (IP_DEFAULT_TTL)
#define LWIP_BROADCAST_PING             0
#define LWIP_MULTICAST_PING             0
#define LWIP_RAW                        1
#define RAW_TTL                        (IP_DEFAULT_TTL)
#define LWIP_DHCP                       0
#define DHCP_DOES_ARP_CHECK             ((LWIP_DHCP) && (LWIP_ARP))
#define LWIP_AUTOIP                     0
#define LWIP_DHCP_AUTOIP_COOP           0
#define LWIP_DHCP_AUTOIP_COOP_TRIES     9
#define LWIP_SNMP                       0
#define SNMP_CONCURRENT_REQUESTS        1
#define SNMP_TRAP_DESTINATIONS          1
#define SNMP_PRIVATE_MIB                0
#define SNMP_SAFE_REQUESTS              1
#define LWIP_IGMP                       0
#define LWIP_DNS                        0
#define DNS_TABLE_SIZE                  4
#define DNS_MAX_NAME_LENGTH             256
#define DNS_MAX_SERVERS                 2
#define DNS_DOES_NAME_CHECK             1
#define DNS_USES_STATIC_BUF             1
#define DNS_MSG_SIZE                    512
#define DNS_LOCAL_HOSTLIST              0
#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC   0
#define LWIP_UDP                        1
#define LWIP_UDPLITE                    0
#define UDP_TTL                         (IP_DEFAULT_TTL)
#define LWIP_TCP                        1
#define TCP_TTL                         (IP_DEFAULT_TTL)
#define TCP_WND                         2048
#define TCP_MAXRTX                      12
#define TCP_SYNMAXRTX                   6
#define TCP_QUEUE_OOSEQ                 (LWIP_TCP)
#define TCP_MSS                         1476
#define TCP_CALCULATE_EFF_SEND_MSS      1
#define TCP_SND_BUF                     32768
#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF)/(TCP_MSS))
#define TCP_SNDLOWAT                    ((TCP_SND_BUF)/2)
#define TCP_LISTEN_BACKLOG              0
#define TCP_DEFAULT_LISTEN_BACKLOG      0xff
#define LWIP_TCP_TIMESTAMPS             0
#define TCP_WND_UPDATE_THRESHOLD   (TCP_WND / 4)
#define LWIP_CALLBACK_API               1
#define PBUF_LINK_HLEN                  14
#define PBUF_POOL_BUFSIZE               1536
#define LWIP_NETIF_HOSTNAME             0
#define LWIP_NETIF_API                  1
#define LWIP_NETIF_STATUS_CALLBACK      1
#define LWIP_NETIF_LINK_CALLBACK        1
#define LWIP_NETIF_HWADDRHINT           0
#define LWIP_NETIF_LOOPBACK             0
#define LWIP_LOOPBACK_MAX_PBUFS         0
#define LWIP_NETIF_LOOPBACK_MULTITHREADING    (!NO_SYS)
#define LWIP_NETIF_TX_SINGLE_PBUF             0
#define LWIP_HAVE_LOOPIF                0
#define LWIP_HAVE_SLIPIF                0
#define TCPIP_THREAD_NAME              "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE          1024
#define TCPIP_THREAD_PRIO               2
#define TCPIP_MBOX_SIZE                 LWIP_Q_SIZE
#define SLIPIF_THREAD_NAME             "slipif_loop"
#define SLIPIF_THREAD_STACKSIZE         0
#define SLIPIF_THREAD_PRIO              1
#define PPP_THREAD_NAME                "pppMain"
#define PPP_THREAD_STACKSIZE            0
#define PPP_THREAD_PRIO                 1
#define DEFAULT_THREAD_NAME            "lwIP"
#define DEFAULT_THREAD_STACKSIZE        1024
#define DEFAULT_THREAD_PRIO             2
#define DEFAULT_RAW_RECVMBOX_SIZE       0
#define DEFAULT_UDP_RECVMBOX_SIZE       0
#define DEFAULT_TCP_RECVMBOX_SIZE       10
#define DEFAULT_ACCEPTMBOX_SIZE         10
#define LWIP_TCPIP_CORE_LOCKING         1
#define LWIP_NETCONN                    1
#define LWIP_SOCKET                     1
#define LWIP_COMPAT_SOCKETS             1
#define LWIP_POSIX_SOCKETS_IO_NAMES     1
#define LWIP_TCP_KEEPALIVE              0
#define LWIP_SO_RCVTIMEO                1
#define LWIP_SO_RCVBUF                  1
#define RECV_BUFSIZE_DEFAULT            2048
#define SO_REUSE                        0
#define LWIP_STATS                      1

#if LWIP_STATS

#define LWIP_STATS_DISPLAY              0
#define LINK_STATS                      1
#define ETHARP_STATS                    (LWIP_ARP)
#define IP_STATS                        1
#define IPFRAG_STATS                    (IP_REASSEMBLY || IP_FRAG)
#define ICMP_STATS                      1
#define IGMP_STATS                      (LWIP_IGMP)
#define UDP_STATS                       (LWIP_UDP)
#define TCP_STATS                       (LWIP_TCP)
#define MEM_STATS                       1
#define MEMP_STATS                      1
#define SYS_STATS                       1

#else

#define LINK_STATS                      0
#define IP_STATS                        0
#define IPFRAG_STATS                    0
#define ICMP_STATS                      0
#define IGMP_STATS                      0
#define UDP_STATS                       0
#define TCP_STATS                       0
#define MEM_STATS                       0
#define MEMP_STATS                      0
#define SYS_STATS                       0
#define LWIP_STATS_DISPLAY              0

#endif /* LWIP_STATS */

#define PPP_SUPPORT                     0
#define PPPOE_SUPPORT                   0
#define PPPOS_SUPPORT                   PPP_SUPPORT

#if PPP_SUPPORT

#define NUM_PPP                         1
#define PAP_SUPPORT                     0
#define CHAP_SUPPORT                    0
#define MSCHAP_SUPPORT                  0
#define CBCP_SUPPORT                    0
#define CCP_SUPPORT                     0
#define VJ_SUPPORT                      0
#define MD5_SUPPORT                     0
#define FSM_DEFTIMEOUT                  6       /* Timeout time in seconds
*/
#define FSM_DEFMAXTERMREQS              2       /* Maximum Terminate-Request
transmissions */
#define FSM_DEFMAXCONFREQS              10      /* Maximum Configure-Request
transmissions */
#define FSM_DEFMAXNAKLOOPS              5       /* Maximum number of nak
loops */
#define UPAP_DEFTIMEOUT                 6       /* Timeout (seconds) for
retransmitting req */
#define UPAP_DEFREQTIME                 30      /* Time to wait for auth-req
from peer */
#define CHAP_DEFTIMEOUT                 6       /* Timeout time in seconds
*/
#define CHAP_DEFTRANSMITS               10      /* max # times to send
challenge */
#define LCP_ECHOINTERVAL                0
#define LCP_MAXECHOFAILS                3
#define PPP_MAXIDLEFLAG                 100

#define PPP_MTU                         1500     /* Default MTU (size of
Info field) */
#ifndef PPP_MAXMTU
/* #define PPP_MAXMTU  65535 - (PPP_HDRLEN + PPP_FCSLEN) */
#define PPP_MAXMTU                      1500 /* Largest MTU we allow */
#endif
#define PPP_MINMTU                      64
#define PPP_MRU                         1500     /* default MRU = max length
of info field */
#define PPP_MAXMRU                      1500     /* Largest MRU we allow */
#ifndef PPP_DEFMRU
#define PPP_DEFMRU                      296             /* Try for this */
#endif
#define PPP_MINMRU                      128             /* No MRUs below
this */


#define MAXNAMELEN                      256     /* max length of hostname or
name for auth */
#define MAXSECRETLEN                    256     /* max length of password or
secret */

#endif /* PPP_SUPPORT */

#define CHECKSUM_GEN_IP                 1
#define CHECKSUM_GEN_UDP                1
#define CHECKSUM_GEN_TCP                1
#define CHECKSUM_CHECK_IP               1
#define CHECKSUM_CHECK_UDP              1
#define CHECKSUM_CHECK_TCP              1
#define LWIP_DBG_MIN_LEVEL              LWIP_DBG_LEVEL_OFF
#define LWIP_DBG_TYPES_ON               LWIP_DBG_OFF
#define ETHARP_DEBUG                    LWIP_DBG_OFF
#define NETIF_DEBUG                     LWIP_DBG_OFF
#define PBUF_DEBUG                      LWIP_DBG_OFF
#define API_LIB_DEBUG                   LWIP_DBG_OFF
#define API_MSG_DEBUG                   LWIP_DBG_OFF
#define SOCKETS_DEBUG                   LWIP_DBG_OFF
#define ICMP_DEBUG                      LWIP_DBG_OFF
#define IGMP_DEBUG                      LWIP_DBG_OFF
#define INET_DEBUG                      LWIP_DBG_OFF
#define IP_DEBUG                        LWIP_DBG_OFF
#define IP_REASS_DEBUG                  LWIP_DBG_OFF
#define RAW_DEBUG                       LWIP_DBG_OFF
#define MEM_DEBUG                       LWIP_DBG_OFF
#define MEMP_DEBUG                      LWIP_DBG_OFF
#define SYS_DEBUG                       LWIP_DBG_OFF
#define TCP_DEBUG                       LWIP_DBG_OFF
#define TCP_INPUT_DEBUG                 LWIP_DBG_OFF
#define TCP_FR_DEBUG                    LWIP_DBG_OFF
#define TCP_RTO_DEBUG                   LWIP_DBG_OFF
#define TCP_CWND_DEBUG                  LWIP_DBG_OFF
#define TCP_WND_DEBUG                   LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG                LWIP_DBG_OFF
#define TCP_RST_DEBUG                   LWIP_DBG_OFF
#define TCP_QLEN_DEBUG                  LWIP_DBG_OFF
#define UDP_DEBUG                       LWIP_DBG_OFF
#define TCPIP_DEBUG                     LWIP_DBG_OFF
#define PPP_DEBUG                       LWIP_DBG_OFF
#define SLIP_DEBUG                      LWIP_DBG_OFF
#define DHCP_DEBUG                      LWIP_DBG_OFF
#define AUTOIP_DEBUG                    LWIP_DBG_OFF
#define SNMP_MSG_DEBUG                  LWIP_DBG_OFF
#define SNMP_MIB_DEBUG                  LWIP_DBG_OFF
#define DNS_DEBUG                       LWIP_DBG_OFF

 
Observed Issue:
Assertion at LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0);


Is this assertion because of calling lwip socket function from another
thread?
Is calling socket function from another thread is allowed?
Are the above configuration parameters are ok? or do we need to change it to
avoid assertion?
Is this thread synchronization issue?

Thanks,
gkn
-- 
View this message in context: 
http://old.nabble.com/Issue-in-multithread-system-tp34446642p34446642.html
Sent from the lwip-users mailing list archive at Nabble.com.




reply via email to

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