lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] [lwip] pbuf alloc/free locks


From: Kieran Mansley
Subject: [lwip-users] [lwip] pbuf alloc/free locks
Date: Thu, 09 Jan 2003 00:02:00 -0000

I'm having problems with the pbuf_pool_free_lock and pbuf_pool_alloc_lock.
They're doing what they're supposed to, and stopping access to the
pbuf_pool from two places at the same time (pbuf_refresh and
pbuf_pool_alloc), but when pbuf_pool_alloc is prevented from getting
access to the pool it pretends it is out of buffers and returns NULL.

This is where thing start to go wrong as the code that has called
pbuf_alloc doesn't then know if it has failed due to a real lack of
memory, or if it's just not been able to get a lock, and it wants to
behave differently in these two situations.

If it were a rare occurence I'd be happy to just try again, but it seems
to happen quite frequently (approx 1% of the time), and trying again won't
help if the thread that has the lock hasn't been run in the meantime.

(As an aside, it seems rather unlucky that pbuf_refresh is getting
interrupted so frequently (which it must be if pbuf_pool_alloc can't
obtain the lock) - perhaps there is a bug elsewhere, or a simple way to
restructure the code so this doesn't happen).

Ideally, in the case where it has buffers but can't get the lock, I'd
like it to block until the lock is available.  However, there might be
reasons why it's not done like this, so I thought I'd ask first.  (It
would require some reworking to do this at it would be at risk of deadlock
as it currently stands)

Any thoughts?

Kieran

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




reply via email to

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