This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Dynamic memory allocation problem

Other Parts Discussed in Thread: TMS320C6748

Hi

I am working TMS320C6748 Processor.

I am facing dynamic memory allocation problem.Whenever i do new ,the processor hangs.Huge Heap memory is allocated through .tcf file.All the section are assigned in external memory.

I am using DSP/BIOS and SWI's(2 Software interrupts).

The code runs smoothly when SWI's are not used.Pls somebody help me on this

 

  • Are you doing the New within the Swi?  And are you assigning the pointer to it to a local variable in the SWI?  

    If yes,  then your pointer to the memory is getting killed when the SWI exits because it was stored on the stack.  If you return the pointer from the SWI, be sure to do so by value, and not by reference.  If you do it by reference, the reference will point to a value on the system stack that will eventually be overwritten.

    If this is not the case, can you provide more specific details about your scenario?


    Regards,

    Dan

  • Can you clarify what you mean by "hangs"?   Can you look in disassembly window and find the program counter?  What function is it in?   BTW, all memory allocation is not allowed from SWI context.   This is because the memory allocator uses a blocking lock to make it thread safe.  You need to do all memory allocations from main() or from a task.

    Thanks,
    -Karl-

  • Hi

    Thanks for the reply.

    I am not doing any memory allocation from SWI.It being done in the task only.

    i went through the disassembly window.The programme counter is pointing at C$L1: It is not coming out of this even setpin is done.

    I am attaching the disassembly file.Pls help me in solving this.

     

     

      

  • Hi

    Thanks for the reply.

    I am not doing new within SWI.I am not assigning any pointer to a local variable SWI.I am just calling a function in a SWI that in turn creates a dynamic memory(new).

    Pls let me know if i am wrong.Also pls help me in solving this.

    Regards

    Shilpa

     

  • You say "I am just calling a function in a SWI that in turn creates a dynamic memory".   This means that you _are_ calling memory allocation from a SWI.  This is not allowed.

    Can you review your disassembly view and see what symbols are above that C$1 (or whatever).   There should be an external symbol above that that gives us a clue.   You should also look in ROV (tools->ROV) and look in the LOG view to see if you see a useful error message.