[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] pbuf_pool_alloc_lock
From: |
Kieran Mansley |
Subject: |
[lwip-users] Re: [lwip] pbuf_pool_alloc_lock |
Date: |
Thu, 09 Jan 2003 00:03:52 -0000 |
On Wed, 6 Mar 2002, Mumtaz Ahmad wrote:
> Hi
>
> whats the purpose of
> pbuf_pool_alloc_lock and
> pbuf_pool_alloc_free
>
> If these are to secure some critical areas in pbuf.c code then they must be
> semaphores
They are there to control access to the list of pbufs - this list is
changed in pbuf_pool_alloc() and pbuf_refresh(), but must only be changed
by one at once.
Semaphores (as implemented in sys_arch.c) would do the same job, but are a
bit heavyweight for this application as they are really condition
variables rather than just plain semaphores. This means you are able to
block on a resource using them. Semaphores in their simplist case are
just mutexes. (I'm not sure I'm explaining this very well - unfortunately
the terms "condition variable", "semaphore" and "mutex" aren't always used
properly or defined rigourously, so it can be confusing!)
So, the reason (I think) they're not semaphores is the pbuf code never
blocks on one of these resources - if it is unable to to obtain one of the
locks it simply returns that it couldn't allocate the memory. Memory
allocation routines need to be fast!
[This message was sent through the lwip discussion list.]