lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Timers in LWIP and socket protection


From: address@hidden
Subject: Re: [lwip-users] Timers in LWIP and socket protection
Date: Mon, 14 Jan 2008 21:53:43 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Hi,

1. There are other timers, but you might not need them (dhcp, arp, autoip, dns, ip_reassembly). Other than that, you are right.
2. Yes, that's correct.
3. The tcp timer is only running when a tcp pcb is registered. This gets triggered from the function tcp_timer_needed() in tcpip.c. This is a rather unclean part of the code, since the prototype resides in tcp.h and is only declared #if NO_SYS == 0. 4. That should be enough. You seem to already know that you mustn't use an lwip socket from 2 threads simultaneously... :-) (I should note that I have never tried it, but if you make sure there are not two (or more) threads accessing the socket's data structures (or mboxes) at a time, you should be fine.)

Simon

Thomas Taranowski schrieb:
the tcpip_init function starts up all the required timers (which happens in tcpip_thread startup). You should not be starting them 'manually'. The timeout handlers usually have a call to sys_timeout that set's itself as the timeout handler, which essentially sets up a periodic timer.

On Jan 14, 2008 12:18 AM, Muhamad Ikhwan Ismail <address@hidden <mailto:address@hidden>> wrote:

    Hi,

    I got some qs on timer functions on lwip, read some thread on it
    previously but it doesnt really answer my qs.
    I ll try to generalize this so that any future user can use this
    thread for the same problem.
    Im using lwip 1.2 porting it on a SMX OS on PowerPC MPC852T. Just
    wanna make sure I am right before i run some multithreading test.

    1. The are 2 timers for the whole stack, which are the arptimer
    and the tcp timer am I right ?

    2. The arptimer is initialized in ethernetif_init  through this
    piece of code :
    sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
    which then will be assign a struct timeout to the tcpip thread's
    timeout (since I call it from the tcpip thread initialization)
    linked list and will be checked and updated each time I wait on
    semaphore or fetch a message. Hence I dont have to call the
    arptimer().
    Am I correct so far ?

    3. My biggest problem is the tcp_timer. It is called by the
    tcpip_tcp_timer by tcpip API. But no other function calls the
    tcpip_tcp_timer
    hence I guess I need to call it myself ? If I do have to call it
    myself, I guess there are 2 ways. One is I call it before I wait
    for semaphore after tcpip_thread finishes the job
    it got with the message it fetched. Or call another thread to call
    tcpip_tcp_timer which is literally bad cause the stack itself is
    not multithreading safe, isnt it?
     If  anyone has done something like this and has tips where I can
    use the timer safely, I'd appreciate any tips.

    4.I am writing a telnet server program which have 2 task, both
    using the same socket for transmit and receive. This is possible
    if i do a critical section protection each time
    the socket does receive or send, preventing simultaneous access on
    the socket, am I right ?

    I am thankful for any answers you could provide me.

    Greetings,
    Ikhwan




    ------------------------------------------------------------------------
    Share life as it happens with the new Windows Live. Start sharing!
    
<http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008>

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




--
Thomas Taranowski
Expert embedded software design/contracting
address@hidden <mailto:address@hidden> (remove the n0sp4m)
------------------------------------------------------------------------

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

No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.0/1216 - Release Date: 09.01.2008 10:16





reply via email to

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