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.

RTOS/PROCESSOR-SDK-DRA7X: Configuring Task_hooks.length in SYSBIOS

Part Number: PROCESSOR-SDK-DRA7X
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

Does anyone know how to configure Task_hooks.length in SYSBIOS. In my application it is set to 1 (verfied by printing the value), but I need to make it a bigger value.

Jakub

  • Hi Jakub,

    You can use the Task.addHookSet function in the .cfg file (you need to edit it as a text file). You can look at the description of the function in the BIOS API Reference (<SYSBIOS install>/docs/cdoc/index.html and navigate to ti.sysbios.knl.Task.

    For example, I added the following into a .cfg file
    Task.addHookSet({
    registerFxn: '&myRegisterFxn1',
    createFxn: '&myCreateFxn1',
    deleteFxn: '&myDeleteFxn1',
    switchFxn: '&mySwitchFxn1'
    });
    Task.addHookSet({
    registerFxn: '&myRegisterFxn2',
    createFxn: '&myCreateFxn2',
    deleteFxn: '&myDeleteFxn2',
    switchFxn: '&mySwitchFxn2'
    });

    and when you look at the generated kernel source file in debug/configPkg/package/cfg/<.cfg filename>_p<target>.c and you'll see the generated array:

    const __T1_ti_sysbios_knl_Task_hooks ti_sysbios_knl_Task_hooks__A[2] = {
    {
    ((xdc_Void(*)(xdc_Int))((xdc_Fxn)myRegisterFxn1)), /* registerFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle,xdc_runtime_Error_Block*))((xdc_Fxn)myCreateFxn1)), /* createFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* readyFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle,ti_sysbios_knl_Task_Handle))((xdc_Fxn)mySwitchFxn1)), /* switchFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* exitFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))((xdc_Fxn)myDeleteFxn1)), /* deleteFxn */
    }, /* [0] */
    {
    ((xdc_Void(*)(xdc_Int))((xdc_Fxn)myRegisterFxn2)), /* registerFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle,xdc_runtime_Error_Block*))((xdc_Fxn)myCreateFxn2)), /* createFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* readyFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle,ti_sysbios_knl_Task_Handle))((xdc_Fxn)mySwitchFxn2)), /* switchFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))0), /* exitFxn */
    ((xdc_Void(*)(ti_sysbios_knl_Task_Handle))((xdc_Fxn)myDeleteFxn2)), /* deleteFxn */
    }, /* [1] */
    };

    Of course, I need to now write those function in my application code otherwise the application will unresolved symbols....

    Todd
  • Hi Todd,


    This is not what I need. I am using the TI's NDK on Jacinto 6 SoC. The socket layer requires that the functions:

        NDK_hookInit(ndkHookId);
        NDK_hookCreate(TaskSelf());

    are called before sockets can be used.

    The NDK_hookCreate() function is:

    void NDK_hookCreate(Task_Handle h)
    {
        hookOK = 1;

        if( hookId != 0xffffffff ) {
            Task_setHookContext(h, (Int)hookId, 0);

            /* open the file descriptor session automatically (if configured to) */
            ti_ndk_config_global_taskCreateHook(h);
        }
    }

    And hookId is set first by calling NDK_hookInit().

    I need a free slot for in task hook contexts, to store NDK specific context, not task hook functions.

    Is there a way to achieve this?

    In debug variant of my application I get crashes when I call NDK_hookCreate(). The crash does not happen when I comment out this call or use a release variant.


    Thanks,

    Jakub

  • Just to be clear, you are trying to use the TaskSetEnv with values of 1, 2 or 3... correct? These are not supported when the underlying OS is TI-RTOS (SYS/BIOS). This is noted in the API reference

    "SYS/BIOS Users Note: The OS adaptation layer (OS.LIB) implements this function for slot 0 only. The reserved slot 0 is the only slot required by the NDK. Slots 1 to 3 are not implemented. You should use the standard SYS/BIOS functions Task_setEnv() and Task_getEnv() for private environment pointer storage and retrieval."

    Todd
  • I am not using TaskSetEnv with values greater 0 in my application. I only call NDK_hookInit(0) and then NDK_hookCreate(TaskSelf()).
  • ok. Please note, you should not be calling either of these functions if you are configuring the NDK in the .cfg file per NDK User Guide

    "The Task adaptation module in the OS library requires a hook to be able to save and load private
    environment pointers for the NDK. This is done by creating a SYS/BIOS hook. A hook module must be
    created to call the OS hook functions NDK_hookInit() and NDK_hookCreate().

    If you use XGCONF to configure the NDK, these objects are all created automatically."

    This infrastructure is not intended to store you private information. You can use the Task_getEnv and Task_setEnv directly to store private information.

    Todd
  • I was mixing two types of configuration: cfg file and Cfg API. After switching to cfg file only, the Task_hooks.length is set to 2.
    Thank you Todd.