|Subject:||[lwip-users] critical section protection + timer issues questions|
|Date:||Thu, 17 Feb 2005 10:52:33 -0800|
I have two questions. The first is regarding multi-threaded code protection and the second involves timers.
First, can someone please explain to me how the lwip code protects itself in a multithreaded environment when threads are using the “raw” interface (tcp_connect(), tcp_write(), etc.)? For example, I see various api calls (tcp_connect() for example) end up calling into sys_timeout() which manipulates the timer linked list. Yet there is no thread protection of any kind around this list manipulation code. Is the calling application supposed to mutex lock all calls into LWIP? Is it because this list is per-thread that it does not need mutex protection?
Regarding timers, I am massively confused. The notes say that sys_arch_timeouts() should return a per-thread linked list head of sys_timeouts. What I don’t understand is what is triggering these timers to fire? For example, I see that the macro TCP_REG() ends up calling tcp_timer_needed() which dutifully gets tcpip_tcp_timer() in the timer list. What I don’t see is where there is any form of timer callback occurring. Is this supposed to occur in sys_arch somewhere? I sort of see that if there’s a semaphore or mailbox being used for that thread that the timers will be dealt with but I do not see where it is guaranteed that there is a semaphore or mailbox always in use for a given thread. For example, if I call tcp_connect() and a resulting timer callback is put into that thread’s timer list, the SYN is sent and then tcp_connect returns. At this point I do not see how that timer for that thread will fire (since LWIP is not waiting on a mailbox or semaphore for that connection)??? Please help me see what it is that I am missing.
|[Prev in Thread]||Current Thread||[Next in Thread]|