lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] multithreaded app ...


From: Kesten, Joerg
Subject: RE: [lwip-users] multithreaded app ...
Date: Tue, 22 Jun 2010 09:14:41 +0200

Hi,

we too ran into big issues with multithreading .. mainly because we missed the 
part in the documentation were it is stated that multithreading is not 
supported ;-)

What worked for us was adding a semaphore in tcpip_apimsg to protect 
simultaneous read and writes on the same connection like this:

err_t
tcpip_apimsg(struct api_msg *apimsg)
{
  struct tcpip_msg msg;

  if (mbox != SYS_MBOX_NULL) {
    sys_sem_wait(apimsg->msg.conn->apisem);               // this is new!
    msg.type = TCPIP_MSG_API;
    msg.msg.apimsg = apimsg;
    sys_mbox_post(mbox, &msg);
    sys_arch_sem_wait(apimsg->msg.conn->op_completed, 0);
    sys_sem_signal(apimsg->msg.conn->apisem);             // this is new!
    return ERR_OK;
  }
  return ERR_VAL;
}

The semaphore is created in netconn_alloc and freed in netcon_free.

Additionally we needed to prevent simultaneous calls to "send" even on 
different sockets. We added a mutex in the send function itself ...

Hope this helps
- Jörg

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of address@hidden
Sent: Montag, 21. Juni 2010 19:21
To: Mailing list for lwIP users
Subject: Re: [lwip-users] multithreaded app ...

Teratux wrote:
> Umm, and what about using mutexes to protect de netconn resource ?? I
> tried it but haven't been able to determine if it's the cause of my
> breaks ...
>    
That should work as long as you make sure that you acquire the mutex 
before *every* usage of the netconn.

BTW: either your clock or your timezone is 4 hours behind, which 
confuses my email client ;-)

Simon

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

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