lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] porting lwIP for CS8900A with UcosII


From: Eric Miniere
Subject: [lwip-users] Re: [lwip] porting lwIP for CS8900A with UcosII
Date: Wed, 08 Jan 2003 22:53:38 -0000

C'est un message de format MIME en plusieurs parties.

------=_NextPart_000_014A_01C15665.DA2A3790
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Adam,

This is about some clarification about Timeout stuff.

You write :

>=20
> Time-outs are functions that are called after a specified amount of =
time. The=20
> time-out functions must not be executed concurrently with the thread =
which=20
> sets the time-out, not can they be called in an interrupt context. =
There are=20
> a couple of ways to implement time-outs and I know of two different=20
> approaches.
>=20
> In my lwIP ports (unix and RTXC), time-outs are processes in the=20
> sys_mbox_fetch() and sys_sem_wait() functions, since threads can be =
suspended=20
> in those functions. Internally, those functions wait either until the=20
> semaphore/mailbox allows the thread to unblock, or until the next =
time-out=20
> should happen. If the thread unblocks because a time-out is scheduled =
to=20
> occur, the corresponding time-out function is called.=20

If we add a new entry timeout (handled by most of OSes) in the =
sys_mbox_fetch() and sys_sem_wait()  functions and the corresponding =
handler(eg : tcp_timer_coarse ) in case of Timeout event, does it works =
?
How do we know the handler to call ?

>=20
> If the thread was unblocked because of a message arriving on the =
mailbox, or=20
> because the semaphore was signalled, the time the thread was waiting =
is=20
> subtracted from the time to the next time-out.

Does it mean that if we wait for message arriving on the mailbox for 400 =
ms=20
and the timeout is defined for 500ms, next time we wait that mailbox, =
the timeout will be of 100ms ?



>=20
> Even though time-outs are measured in microseconds, in the current =
lwIP code=20
> it is not terribly important that they occur at the very right time.=20
> Currently, time-outs are used only by the TCP code.
>=20
> The other approach taken to the implementation of time-outs is the one =
taken=20
> by Hongsong Li in his lwIP port to uC/OS 1.09; instead of processing=20
> time-outs within the sys_mbox_fetch() and sys_sem_wait() functions, he =
has a=20
> separate thread that schedules the time-outs and at the right time =
send a=20
> message to the mailbox in the lwIP main loop in api/tcpip.c. When this =

> message is received, the time-out function is called within the TCP/IP =
thread.
>=20

This means that in this thread, the time-out function can be called if =
the mailbox is not received on time ?
If yes, which one tcp_timer_coarse or tcp_timer_fine ?



> For the 0.5 version of lwIP, the time-out scheduling (which is the =
most=20
> complex part of the OS emulation layer) will be moved out of the =
sys_arch=20
> file and into a generic implementation. The sys_sem_wait and =
sys_mbox_fetch=20
> functions will be redesigned so that they take an extra argument which =
is the=20
> maximum time to wait before unblocking and returning to the caller. =
This will=20
> map nicely onto many OSes and will make it easier to port lwIP to =
other=20
> platforms.

I am not that familiar with TCP/IP but I tried to understand this logic =
...
It seems easier to start reprogramming those 2 functions with Timeout =
functionality included but
I am not sure of the load of work, and the consequence on lwIP code  ?


best regards,

Eric Miniere


------=_NextPart_000_014A_01C15665.DA2A3790
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>Hello Adam,</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This is about some clarification about =
Timeout=20
stuff.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>You write :</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&gt; <BR>&gt; Time-outs are functions that are called after a =
specified=20
amount of time. The <BR>&gt; time-out functions must not be executed=20
concurrently with the thread which <BR>&gt; sets the time-out, not can =
they be=20
called in an interrupt context. There are <BR>&gt; a couple of ways to =
implement=20
time-outs and I know of two different <BR>&gt; approaches.<BR>&gt; =
<BR>&gt; In=20
my lwIP ports (unix and RTXC), time-outs are processes in the <BR>&gt;=20
sys_mbox_fetch() and sys_sem_wait() functions, since threads can be =
suspended=20
<BR>&gt; in those functions. Internally, those functions wait either =
until the=20
<BR>&gt; semaphore/mailbox allows the thread to unblock, or until the =
next=20
time-out <BR>&gt; should happen. If the thread unblocks because a =
time-out is=20
scheduled to <BR>&gt; occur, the corresponding time-out function is =
called.=20
</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>If we add a new entry timeout (handled by most of OSes) in the=20
sys_mbox_fetch() and sys_sem_wait()&nbsp; functions and the =
corresponding=20
handler(eg : tcp_timer_coarse ) in case of Timeout event, does it works =
?</DIV>
<DIV>How do we know the handler to call ?</DIV><FONT face=3DArial =
size=3D2></FONT>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT><FONT=20
face=3DArial size=3D2></FONT><BR>&gt; <BR>&gt; If the thread was =
unblocked because=20
of a message arriving on the mailbox, or <BR>&gt; because the semaphore =
was=20
signalled, the time the thread was waiting is <BR>&gt; subtracted from =
the time=20
to the next time-out.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>Does it mean that if we wait for message arriving on the mailbox =
for 400=20
ms&nbsp;</DIV>
<DIV>and the timeout is defined for 500ms, next time we wait that =
mailbox, the=20
timeout will be of 100ms ?</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT><BR>&gt; <BR>&gt; Even though =
time-outs are=20
measured in microseconds, in the current lwIP code <BR>&gt; it is not =
terribly=20
important that they occur at the very right time. <BR>&gt; Currently, =
time-outs=20
are used only by the TCP code.<BR>&gt; <BR>&gt; The other approach taken =
to the=20
implementation of time-outs is the one taken <BR>&gt; by Hongsong Li in =
his lwIP=20
port to uC/OS 1.09; instead of processing <BR>&gt; time-outs within the=20
sys_mbox_fetch() and sys_sem_wait() functions, he has a <BR>&gt; =
separate thread=20
that schedules the time-outs and at the right time send a <BR>&gt; =
message to=20
the mailbox in the lwIP main loop in api/tcpip.c. When this <BR>&gt; =
message is=20
received, the time-out function is called within the TCP/IP =
thread.<BR>&gt;=20
</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>This means that in this thread, the time-out function can be called =
if the=20
mailbox is not received on time ?</DIV>
<DIV>If yes, which one tcp_timer_coarse or tcp_timer_fine ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&gt; For the 0.5 version of lwIP, the time-out scheduling =
(which is the=20
most <BR>&gt; complex part of the OS emulation layer) will be moved out =
of the=20
sys_arch <BR>&gt; file and into a generic implementation. The =
sys_sem_wait and=20
sys_mbox_fetch <BR>&gt; functions will be redesigned so that they take =
an extra=20
argument which is the <BR>&gt; maximum time to wait before unblocking =
and=20
returning to the caller. This will <BR>&gt; map nicely onto many OSes =
and will=20
make it easier to port lwIP to other <BR>&gt; platforms.<BR></DIV>
<DIV>I am not that familiar with TCP/IP but I tried to understand this =
logic=20
...</DIV>
<DIV>It seems easier to start reprogramming those 2 functions with =
Timeout=20
functionality included but</DIV>
<DIV>I am not sure of the load of work, and the consequence on lwIP=20
code&nbsp;&nbsp;?</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>best regards,</DIV>
<DIV><BR>Eric Miniere<BR></DIV></BODY></HTML>

------=_NextPart_000_014A_01C15665.DA2A3790--

[This message was sent through the lwip discussion list.]




reply via email to

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