avr-libc-dev
[Top][All Lists]
Advanced

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

RE: [avr-libc-dev] malloc changes


From: Stu Bell
Subject: RE: [avr-libc-dev] malloc changes
Date: Fri, 10 Apr 2009 02:59:13 -0600

Whenever the stack/heap configuration is anything other than normal, it
is likely that malloc/calloc is not going to work the way you think it
should.  In particular, when dealing within RTOS that has a separate
context of "stack", it is almost assured that malloc won't work.

In FreeRTOS they set aside a separate "heap" that separate routines then
allocate/free.  Check out their Memory Manager routines.

I'm somewhat surprised that AVRX does not provide some solution, even if
it is not required.

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 

 

> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden 
> On Behalf Of DarkDragon
> Sent: Thursday, April 09, 2009 10:59 PM
> To: address@hidden
> Subject: Re: [avr-libc-dev] malloc changes
> 
> 
> Found the source to malloc and it looks like the cause is the 
> following code inserted in AVR LibC 1.6.5:
> 
> if (cp <= __brkval)
>  /*
>   * Memory exhausted.
>   */
>  return 0;
> 
> If I read this correctly, since the AVRX task stack is under 
> __brkval, malloc won't work if called from a task.
> 
> Maybe I can put a wrapper around malloc to repoint the stack 
> pointer so that this line is valid:
> cp = STACK_POINTER() - __malloc_margin;
> 
> --
> View this message in context: 
> http://www.nabble.com/malloc-changes-tp22982993p22983132.html
> Sent from the AVR - Libc - Dev mailing list archive at Nabble.com.
> 
> 
> 
> _______________________________________________
> AVR-libc-dev mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-libc-dev
> 




reply via email to

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