[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] Re: [lwip] memp_malloc
From: |
Adam Dunkels |
Subject: |
[lwip-users] Re: [lwip] memp_malloc |
Date: |
Thu, 09 Jan 2003 01:27:55 -0000 |
On Thursday 07 March 2002 10.23, you wrote:
> > Why does the code use memp_malloc at some places and memp_mallocp at
> > others . I think if the code has to be run in mutithreading environment
> > then memp_mallocp must always be used since this function is gaurded by
> > semaphores .
>
> ...unless you know that resource will only be accessed by one thread.
> Having had a look at the code (I don't know if this is right, but it looks
> this way to me) the only places that use memp_malloc are in api_lib.c and
> they are all requesting memory of the same type (MEMP_API_MSG). This type
> is not requested from anywhere else, and the code in api_lib.c is always
> executed by the same thread (I think!), so by not protecting it with
> semaphores you should get a significant increase in performance. (API
> msgs are still a big bottleneck, but it'd be worse otherwise)
>
> Could all be wrong though. Adam will be along shortly to correct me...
You are right (as usual :-). But, as Mumtaz points out, code run in different
threads must be protected by semaphores (as the mallocp/freep functions
does). Since the api_lib code can be executed by different threads in
parallell, they *should* in fact be protected.
Bug in lwIP.... new release coming out shortly :-)
/adam
--
Adam Dunkels <address@hidden>
http://www.sics.se/~adam
[This message was sent through the lwip discussion list.]