lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Compile errors with lwip 0.7.0 and contrib-20040122


From: Peter Graf
Subject: Re: [lwip-users] Compile errors with lwip 0.7.0 and contrib-20040122
Date: Wed, 28 Jan 2004 16:03:16 +0100
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4

John Taylor wrote:

Another thing that has puzzled me a bit, is that sys_msleep() is now
forced to use the overhead of allocating and deallocating a semaphore
on every call. Wouldn't it be better to allow sys_msleep() to be
implemented in sys_arch.c?
I remember looking at that long ago and I am not sure why but did not
change anything. Maybe the fact that it uses lwip semaphores allows lwip
timers to fire whereas a native sleep would not trigger the timers of
the sleeping thread.You could check and see if that's the case, I'll doit with 
the ecos port sometime soon.

IIRC that's not the case. So far sys_msleep() is only used for PPP, where native sleep had been working OK.
No, the sys_msleep() call is required for the lwip timers to fire
properly.

sys_msleep() is not required for the lwIP timers at all. Just do a find/grep on 
the code and you'll see that it is nowhere called except from PPP. I have lwIP 
running nicely with sys_msleep() compeletely removed.

If there's a technical need for the usage of semaphores here, it must be PPP 
specific, but I doubt even that. AFAICS sys_msleep() seems only to be used 
there during password check, waiting for the link, close, and when handling an 
exceptional return of sio_read.

Using a native sleep will delay the firing of all 'active'
timers at the time the sleep call is made.

In a multitasking OS, there's no good reason why a sleeping task should delay any timers. And for non-multitasking lwIP, sys_msleep() isn't defined. BTW I didn't even say I wish a native call, just sys_arch.c to layer it.

 Now, if there are no
'active' timers when the thread is sleeping - no harm, no foul.  Or if
the amount of time spent sleeping is relatively small compared to the
timer period, it is probably not noticeable.  However, as good practice,
I recommend *not* replacing the sys_msleep() with a native sleep call.
Implementing it in sys_arch.c means not necessarily a direct native replacement.

FYI: This is fresh on my mind, because I too thought the implementation
of sys_msleep() was "klunky" until I completely understood how lwip
timers work - then it make perfect sense.
Disagreed :-)

All the best
Peter





reply via email to

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