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.

MSP432E411Y-BGAEVM: Task name in ROV for C++ application

Part Number: MSP432E411Y-BGAEVM

I am porting a Linux C++ application to run under TI RTOS.

To use overridden, derived class methods as the task function, I have implemented an extern "C" function as an intermediate step - 

extern "C" void * ThreadEntry(CBaseThreadClass * arg)
{
    return arg->ThreadRuntime();
}

This just needs to be passed to pthread_create with "this" as the argument.

bool CBaseThreadClass::StartThread()
{
    ...
    int retc = pthread_create(&m_thread, &m_attributes, (THREADFUNCPTR)ThreadEntry, this);
    ...

Seems to work - so far, so good!

Unfortunately, in the ROV, all tasks have "ThreadEntry" in the "fxn" column, so it is a bit hard to tell them apart.

I see a nice useful looking column called "label". This is empty for all but "ti.sysbios.knl.Task.IdleTask". Is there a way that I can set this for my tasks so I can tell which is which?

Thanks
 

  • Is there a way that I can set this for my tasks so I can tell which is which?

    pthread_create() calls Task_create() to dynamically create the underlying SYS/BIOS task.

    For a task created by Task_create() to have a label shown in ROV requires that:

    a. The SYS/BIOS configuration .cfg file has the following to set the namedInstance parameter to true:

    var Task = xdc.useModule('ti.sysbios.knl.Task');
    Task.common$.namedInstance = true;

    b. The taskParams.instance->name passed to Task_create() has the string for label set.

    The SYS/BIOS pthread_create() function in  simplelink_msp432e4_sdk_4_20_00_12/source/ti/posix/tirtos/pthread.c isn't setting the taskParams.instance->name field to label the created task for ROV.

    Looking at SYS/BIOS I can't see any function which is provided to set the name of a thread after it has been created,

    In the attached example project created some new pthread_setname_np.c and pthread_setname_np.h source files which implement the GNU extension pthread_setname_np() provided under Linux, where the pthread_setname_np() sets the name which is visible to ROV for the underlying SYS/BIOS task. To do that, the pthread_setname_np.c source file had to include some private SYS/BIOS source files, and so may break with later SYS/BIOS changes. However, at least encapsulated in one source file.

    The example code calls pthread_setname_np() after pthread_create():

        retc = pthread_create(&thread, &attrs, consoleThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1) {}
        }
        pthread_setname_np (thread, "console thread");
    
        retc = pthread_create(&thread, &attrs, temperatureThread, NULL);
        if (retc != 0) {
            /* pthread_create() failed */
            while (1) {}
        }
        pthread_setname_np (thread, "temperature thread");
    

    And the labels show up in ROV:

    The example project with the pthread_setname_np.c and pthread_setname_np.h source files MSP432E401Y_tirtos_ccs_pthread_setname_np.zip

    And the SYS/BIOS configuration which has namedInstance set true tirtos_builds_MSP_EXP432E401Y_release_ccs.zip

  • Thanks, that does the trick!

    My TI RTOS release.cfg already contained, (near the end):

    var Task = xdc.useModule('ti.sysbios.knl.Task');
    var ndkHooks = new Task.HookSet();
    ndkHooks.registerFxn = '&NDK_hookInit';
    Task.addHookSet(ndkHooks);
    

    So All I had to do was add:

    Task.common$.namedInstance = true;

    After building that, the ROV task view now shows labels "DHCPclient" and "ndkStackThread", as these are created with generated code that uses the native TI RTOS calls rather than the Posix wrapper.

    For now, I have included the pthread_setname_np.c/h files from your zip in my project rather than in the TI RTOS project.

    Since the project is C++, I had to wrap the function prototype for pthread_setname_np() in a:

    #ifdef __cplusplus
    extern "C"
    {
    #endif
    
    int pthread_setname_np(pthread_t thread, const char *name);
    
    #ifdef __cplusplus
    }
    #endif
    

    Then, my base thread class can set a passed in name. Slight smile

    Thanks

    Jim

  • I looked before (badly), and failed to spot that Task.common$.namedInstance = true; can also be set in the TI RTOS project GUI editor: