lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] tcp_write() errors on snd_queuelen


From: Simon Goldschmidt
Subject: RE: [lwip-users] tcp_write() errors on snd_queuelen
Date: Wed, 16 Mar 2011 17:15:39 +0100

If you try to protect tcp_write() against the ETH interrupt by disabling 
interrupts, that would mean you would have to *always* disable the ETH 
interrupt while calling into lwIP. That's pretty unperformant, I think.

As I already said before, the lwIP way is to prevent the driver calling into 
lwIP from interrupt context.


Tim Lambrix <address@hidden> wrote:
> Andrew,
> Thanks for your help too. I will take all I can get right now.  It looks
> like SYS_ARCH_PROTECT is defined as follows and it does hit this line of
> code (only from the interrupt itself however):
>       sys_prot_t
>       sys_arch_protect(void)
>       {
>               return((sys_prot_t)MAP_IntMasterDisable());
>       }
> I think this is correct?

It seems like a correct implementation of sys_arch_protect, yes.

> However, the stellarisif_transmit function you
> mention is called in three places and only one of them has the
> SYS_ARCH_PROTECT called before it.  I don't see the calls in the interrupt 
> itself
> stellarisif_interrupt.

That's because you don't need to disable interrupts in an ISR, I guess (unless 
there can be a nested interrupt with a higher priority from which you need to 
protect yourself).

> Maybe I am missing something here but the problem I seem to have is the
> Ethernet interrupt goes off while I am in the tcp_write->tcp_enqueue function
> and changes the values of pcb->snd_queuelen.

Not really. The problem is only that the Ethernet interrupt seems to call into 
lwIP where it shouldn't.

> I have modified the local
> variable in that function queuelen to not use the value read at line 195 from:
> 
>       queuelen = pcb->snd_queuelen;    to
>       queuelen = 0;
> 
> and line 411 from:
> 
>       pcb->snd_queuelen = queuelen;    to
>       pcb->snd_queuelen += queuelen;
> 
> This fixes the issue but I welcome your insight on why it should not
> happen in the first place.

That's only one of many things which won't work: lwIP is simply not designed to 
work in that scenario!

> I don't see any calls close to SYS_ARCH_PROTECT in
> the tcp_write function to prevent the interrupt from going off.

Again, lwIP's core is not designed for multithreading, that's why there are not 
SYS_ARCH_PROTECT calls. It would be pretty unperformant to disable interrupts 
for the whole call to tcp_write!


I really could help you more if I had insight on the code you are using.

Simon
-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl



reply via email to

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