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.

BIOS Heap and thread safety

Other Parts Discussed in Thread: SYSBIOS, TMS320F28335, CC3200

I cat'n find out how does BIOS heap operates with gates.

I define BIOS's heap in app.cfg like this:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var HeapTrack = xdc.useModule('ti.sysbios.heaps.HeapTrack');
BIOS.heapSize = 0x4000;
BIOS.heapTrackEnabled = true;

Do I have to take steps to protect heap corruptness during multi thread usage?

Is it safe to allocate new records in std::map<...> in different thread simultaneous?

  • Baranov,

    Which device and which version of TI-RTOS are you using?

    Also, if you haven’t seen it, there is some description of the different Heap implementations, and configuring a specific Gate type, in the SYS/BIOS User’s Guide (Bios_User_Guide.pdf in the “docs” subdirectory of the SYS/BIOS kernel installation).

    Thanks,
    Scott

  • We're using TMS320F28335 and TI/RTOS 2.10.01.38.

    Yes, I've seen this, but I didn't get how to configure the heap which created by BIOS. Does this heap uses ti.sysbios.gates.GateMutexPri by default?

  • By default the system heap is created using a HeapMem instance (see 7.7.2, Specifying the Default System Heap).  And by default, HeapMem uses GateMutex for a lock. 

    But you can change it to a different gate type, for example as shown in 7.8.2:

    var GateMutexPri = xdc.useModule('ti.sysbios.gates.GateMutexPri');
    var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
    HeapMem.common$.gate = GateMutexPri.create();

    If you open up the RTOS Object Viewer (ROV) after starting your program, you can see the gate configuration.  Click on HeapMem, then the Raw tab, then Configuration, and then common$, and look at $name.  For example (for a CC3200 that I have handy):


    You’d asked if it was safe to use with std::map<>.  I think that the gate you choose will be used here.  But I’m not absolutely positive.  I think to verify whether this is the case, you can run your app to a breakpoint just before the call.  Then set a breakpoint on the gate enter function (for example ti_sysbios_gates_GateMutexPri_enter__E()), and run.  I think you should see the breakpoint stop the CPU.  Then look in the callstack to see the gate used for the allocation.  For example, I tried this on my board for a simple malloc call and saw the callstack:

    Hope this helps.

    Regards,
    Scott

  • Yes, that is true, checked on hw..
    Thank you!