[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL
From: |
Leon Woestenberg |
Subject: |
Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL |
Date: |
Thu, 16 Nov 2006 20:14:47 +0100 |
Hello all,
On Sun, 2006-11-12 at 01:43 +0000, Jonathan Larmour wrote:
> Leon Woestenberg wrote:
> > The SYS_LIGHTWEIGHT_PROT protection was introduced by one of the
> > developers using the stack to protect *ONLY* between interrupt context
> > and single-thread user-space context if I am not mistaken.
> >
> > I am all for removing it, because the locking solution does not scale
> > across different platforms.
>
> I was actually arguing the other way round I'm afraid :-). I was arguing
>
As said, I have been away from the lwIP stack too long, so I should have
shut up in the first place. However...
> that it looks to me that SYS_LIGHTWEIGHT_PROT is essentially mandatory
> because packets arrive asynchronously and so pbuf allocation needs to have
> some protection no matter what since the allocation will take place from a
> device driver. That would be true whatever the context, or whether single
> or multi-threaded.
>
In a fully pre-emptive environment (like full-blown eCos), this
light-weight locking mechanism must then disable the Ethernet chip
receive interrupt, to prevent concurrent access to the pbufs, during
LIGHTWEIGHT_PROT locks from non-interrupt context.
I would certainly design a pre-emptive system by NOT entering the pbuf
layer from interrupt context, but instead schedule a high-priority
real-time task to move the packets of the chip from the interrupt
handler, and nothing more.
We have a proven real-time pre-emptive design (even with nested
pre-emptable interrupts) that does not use SYS_LIGHTWEIGHT_PROT but uses
the "bottom-half" approach.
This is using the open-source, non-free uCOS-II RTOS.
If I am completely mistaken, I will probably be corrected by my
colleague Christiaan :-)
> The !SYS_LIGHTWEIGHT_PROT code simply doesn't give any thread or interrupt
> safety at all. So in fact the !SYS_LIGHTWEIGHT_PROT code does not appear
> to solve the problem it seems intended to solve. Hence me saying that that
> code should be removed entirely since as far as I can tell it doesn't
> achieve anything. If protection is needed, something using
> SYS_LIGHTWEIGHT_PROT is the solution.
I am NOT sure if SYS_LIGHTWEIGHT_PROT protects against all concurrent
acccess possible, I thought this was exactly the reason why it was
called lightweight when introduced.
Pushing a packet into the stack will have a chain reaction where all
higher-level layers are called into. I would not run this from interrupt
context.
I am against removing the !SYS_LIGHTWEIGHT_PROT code for the above
reasons. :-)
Regards,
Leon.
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Leon Woestenberg, 2006/11/11
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Jonathan Larmour, 2006/11/11
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL,
Leon Woestenberg <=
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Jonathan Larmour, 2006/11/16
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Christiaan Simons, 2006/11/17
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Mumtaz Ahmad, 2006/11/17
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Andrew Lentvorski, 2006/11/18
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Mumtaz Ahmad, 2006/11/19
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Andrew Lentvorski, 2006/11/20
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Jonathan Larmour, 2006/11/17
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Jonathan Larmour, 2006/11/17
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Kieran Mansley, 2006/11/19
- Re: [lwip-users] Bug in pbuf.c regarding PBUF_POOL, Leon Woestenberg, 2006/11/19