lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Simple Multithreading question


From: Muhamad Ikhwan Ismail
Subject: [lwip-users] Simple Multithreading question
Date: Tue, 8 Jan 2008 11:33:07 +0000


Hi !

I know its a bit too late but still Happy New Year !

I am on the final phase of my project in implementing lwip v1.2 into PowerPC based MPC852T running an SMX OS.
The single thread seems to work. The driver input and output goes through tcpip_thread, and the OS emulation layer
is working fine, and the intertask communication between the netconn API and the TCPIP thread works too.
Following are my questions :

1 There is a piece of code in that puzzles me a little bit and could someone explain this piece ?

if ((msg = (struct api_msg*)memp_malloc(MEMP_API_MSG)) == NULL) {
     return ERR_MEM;
   }
   msg->type = API_MSG_CONNECT;
   msg->msg.conn = conn; 
   msg->msg.msg.bc.ipaddr = addr;
   msg->msg.msg.bc.port = port;
   api_msg_post(msg);
   sys_mbox_fetch(conn->mbox, NULL);
   memp_free(MEMP_API_MSG, msg);
 
  in netconn_connect() upon creating the message and posting it, why are we fetching it back and then deallocate the messages.
  I thought that the msg was meant to passed to the tcpip_thread ? And why are we deallocating the message now ? shouldnt we
 deallocate the message after the tcpip thread finish working on it? This piece of code would work in a single tcpip thread. But what if
 I have multiple tcpip_thread in which i might end up overwriting a message before it can be received by a tcpip_thread.

2. I am suppose to make the whole thing now multithreading safe. There will be multiple task which can open up to 64 sockets in total to handle the
    communication in and out. My question is, can I have a multiple tcpip_thread servicing all this sockets, or may i just have one ? If I can is there anything I need
   to be aware about other than simply creating multiple tcpip_thread and those which have been discussed in the mailing list ?

Thanks a lot for your answers. I really appreciate it.

Greetings
Ikhwan

 



Watch “Cause Effect,” a show about real people making a real difference. Learn more

reply via email to

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