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:C++应用程序 ROV 中的任务名称

Guru**** 656470 points
Other Parts Discussed in Thread: SYSBIOS
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1062581/msp432e411y-bgaevm-task-name-in-rov-for-c-application

器件型号:MSP432E411Y-BGAEVM
Thread 中讨论的其他器件:SYSBIOS

我正在移植 Linux C++应用程序以在 TI RTOS 下运行。

为了将被覆盖的、派生的类方法用作任务函数、我实现了一个 extern "C"函数作为中间步骤-  

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

这只需将"thes"作为参数传递给 pthread_create。

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

似乎是在工作——到目前为止,太好了!

遗憾的是、在 ROV 中、所有任务在"fxn"列中都有"ThreadEntry"、因此很难区分它们。

我看到一个很有用的称为"label"的列。 对于"ti.sysbios.KNL.Task.IdleTask"以外的所有器件、此位为空。 我是否有办法为任务设置此项、以便我知道哪项是什么?

谢谢
 

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [报价 userid="500257" URL"~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1062581/msp432e411y-bgaevm-task-name-in-rov-for-c-application "]我是否可以为我的任务设置此项,以便我知道哪项是?

    pthread_create()调用 Task_create()以动态创建底层 SYS/BIOS 任务。

    要使  Task_create()创建的任务具有 ROV 中显示的标签,需要:

    a. SYS/BIOS 配置.cfg 文件具有以下特性来将 namedInstance 参数设置为 true:

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

    b. 传递给 Task_create()的 taskParams.instance->name 具有标签集的字符串。

      simplelink_msp432e4_sdk_4_20_00_12/source/ti/posix/tirtos/pthread.c 中的 SYS/BIOS pthread_create ()函数未设置 taskParams.instance->name 字段来为 ROV 标记创建的任务。

    查看 SYS/BIOS、我看不到任何函数、这些函数是在创建线程后用于设置线程名称的、

    在随附的示例工程中、创建了一些新 的 pthread_setname_np.c 和 pthread_setname_np.h 源文件、这些文件实现 了 Linux 下提供的 GNU 扩展名 pthread_setname_np()、其中 pthread_setname_np()设置了基础 SYS/BIOS 任务的 ROV 可见的名称。 为此、 pthread_setname_np.c 源文件必须包含一些专用 SYS/BIOS 源文件、因此可能会随着后续 SYS/BIOS 更改而中断。 但是、至少封装在 一个源文件中。

    示例代码在  pthread_create()之后调用 pthread_setname_np():

        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");
    

    标签显示在 ROV 中:

    包含 pthread_setname_np.c 和 pthread_setname_np.h 源文件 e2e.ti.com/.../MSP432E401Y_5F00_tirtos_5F00_ccs_5F00_pthread_5F00_setname_5F00_np.zip 的示例项目

     具有 namedInstance 的 SYS/BIOS 配置设置为 true e2e.ti.com/.../tirtos_5F00_builds_5F00_MSP_5F00_EXP432E401Y_5F00_release_5F00_ccs.zip

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢、这就是诀窍!

    我的 TI RTOS release.cfg 已包含(即将结束):

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

    因此、我只需添加:

    Task.common$.namedInstance = true;

    构建后、ROV 任务视图现在显示标签"DHCPclient"和"ndkStackThread"、因为这些标签是使用生成的代码创建的、这些代码使用本地 TI RTOS 调用而不是 POSIX 包装程序。

    目前、我已将 zip 文件中的 pthread_setname_np.c/h 文件包含在我的项目中、而不是 TI RTOS 项目中。

    由于项目是 C++、我必须将 pthread_setname_np()的函数原型封装到:

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

    然后、我的基线程类可以设置传递的名称。

    谢谢

    Jim

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我以前看过(糟糕的)、但未能发现  Task.common$.namedInstance = true;也可以在 TI RTOS 项目 GUI 编辑器中设置: