lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] sys_msleep() implementation


From: address@hidden
Subject: Re: [lwip-users] sys_msleep() implementation
Date: Tue, 06 May 2008 18:26:25 +0200
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)

Hi Marko,

What Piero said is correct: the code 'blocks' on a semaphore using sys_sem_wait. In contrast to sys_arch_sem_wait (note the 'arch' in the name) or your proposed OS_sleep, sys_sem_wait only blocks for a specific time.

Example: if you have the ARP timer running (5 seconds interval) and call sys_msleep(15000), the code in sys_sem_wait will sleep 5 seconds, process the ARP timer callback, sleep 5 seconds, and so on. This is repeated until the original time passed to sys_msleep has passed.

This is what the comment says: "Timeouts are processed while sleeping."
The actual blocking on the semaphore (with a specific timeout) is done with the (arch-dependent) function sys_arch_sem_wait.

So the simple answer to your original question is: No, you cannot use your OS'es sleep function since timeouts are not processed while sleeping and the stack depends on them. (More advanced answer: in application threads, you may use the OSes sleep function directly, since timeouts are only used in the tcpip_thread.)

Simon


Marko Panger wrote:
Hi,

In the original implementation it blocks anyway by pending on semaphore. The effect is the same. Its just the implementation as I see it, but I could be wrong.

marko

Piero 74 wrote:
Hi marko

the comment of this function said:

 * Sleep for some ms. Timeouts are processed while sleeping.
 *
(and you can see how work in the lwip code) Lwip needs to checks its timeout list during sleep operation, so, you cannot block it using RTOS delay

Someone can confirm my answer?

Bye, Piero.

2008/5/6 Marko Panger <address@hidden <mailto:address@hidden>>:

    Hi all,

    I was looking at the implementation of sys_msleep() function in
    sys.c. As per default in crates
    a semaphore and then pends on it for the timeout value. Could I
    redefine this function in sys_arch.c
    to better suit my RTOS or is there any particular reason for such
    implementation ?

    For example I would implement it as:

    void sys_msleep(u32_t ms) {
      TSK_Sleep(ms);   }

    Any thoughts ?

    Thanks,
    Marko



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


------------------------------------------------------------------------

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



_______________________________________________
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]