lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] Major critical region issues in pbuf.c


From: David Haas
Subject: [lwip-users] [lwip] Major critical region issues in pbuf.c
Date: Wed, 08 Jan 2003 23:24:54 -0000

This is a multi-part message in MIME format.

------=_NextPart_000_00E1_01C29BAD.0FD28EA0
Content-Type: text/plain;
        charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Hi,

As I am starting to debug my implementation I am running into some major =
critical region issues in pbuf.c. In my particular case I have different =
threads doing pbuf allocations and deallocations at the same time =
(actually, it's a series of ISRs and a thread, but that story is for a =
different email). Just as an example of the problems I am having:

pbuf_free() decrements the reference count using p->ref--; and then =
tests it. Well, my compiler loads p->ref into a register, decrements it =
and then stores it back into memory. If, during this time, pbuf_free() =
is called again on the same pbuf we will have problems. I actually found =
this because my low_level_output() increments ref when the pbuf is =
queued for output. Then at a later time when the output has occurred, an =
ISR schedules a function to call pbuf_free(). It just so happens that =
this pbuf_free() interrupts the pbuf_free() from the tcpip_thread. I am =
very lucky to have found this so fast.

So I started examining the code and I see problems if pbuf_pool_alloc() =
is called from two different threads and happen to interrupt each other =
while pbuf_pool_alloc_cache is being accessed. I think there are similar =
problems throughout this code. This stuff needs to be protected!

See my next email for my suggestion on protection.


David.


David Haas
NBS Card Technology
70 Eisenhower Drive,
Paramus, NJ 07652
Voice: 201-845-7373 x183
Fax: 201-845-3337
email: address@hidden

------=_NextPart_000_00E1_01C29BAD.0FD28EA0
Content-Type: text/html;
        charset="Windows-1252"
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=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>As I am starting to debug my implementation I am =
running into=20
some major critical region issues in pbuf.c. In my particular case I =
have=20
different threads doing pbuf allocations and deallocations at the same =
time=20
(actually, it's a series of ISRs and a thread, but that story is for a =
different=20
email). Just as an example of the problems I am having:</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>pbuf_free() decrements the reference count using =
p-&gt;ref--;=20
and then tests it. Well, my compiler loads p-&gt;ref into a register, =
decrements=20
it and then stores it back into memory. If, during this time, =
pbuf_free() is=20
called again on the same pbuf we will have problems. I actually found =
this=20
because my low_level_output() increments ref when the pbuf is queued for =
output.=20
Then at a later time when the output has occurred, an ISR schedules a =
function=20
to call pbuf_free(). It just so happens that this pbuf_free() interrupts =
the=20
pbuf_free() from the tcpip_thread. I am very lucky to have found this so =

fast.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>So I started examining the code and I see problems =
if=20
pbuf_pool_alloc() is called from two different threads and happen to =
interrupt=20
each other while pbuf_pool_alloc_cache is being accessed. I think there =
are=20
similar problems throughout this code. This stuff needs to be=20
protected!</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>See my next email for my suggestion on=20
protection.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>David.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>David Haas<BR>NBS Card Technology<BR>70 Eisenhower=20
Drive,<BR>Paramus, NJ 07652<BR>Voice: 201-845-7373 x183<BR>Fax:=20
201-845-3337<BR>email: <A=20
href=3D"mailto:address@hidden";>address@hidden</A><BR></FONT></DIV><=
/BODY></HTML>

------=_NextPart_000_00E1_01C29BAD.0FD28EA0--

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




reply via email to

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