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/AM5728: SMP test shows a15_1 not work

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

I have created a smp project which has two tasks. One task's affinity is 0 and the other is 1. But when I test the project, it's showed all task run on a15_0.  The console is following:

 main
Core0: Task0 setting task1's new affinity.
Core0: Task1 setting task0's new affinity

And follows is the code:

/*
 *  ======== main.c ========
 */

#include <xdc/std.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/hal/Core.h>

#include <ti/sysbios/knl/Task.h>

#include <ti/drv/uart/UART_stdio.h>

#include <ti/board/board.h>
/*
 *  ======== Global Variable Declaration ========
 */


Task_Handle tsk0, tsk1;
volatile Bool tsk0Done = FALSE, tsk1Done = FALSE;

/*
 *  ======== taskFxn ========
 */
Void myTask0(UArg arg0, UArg a1)
{
    UInt newCoreId = arg0, oldAffinity;

    System_printf ("Core%u: Task0 setting task1's new affinity. \n", Core_getId());
    UART_printf("Core%u: Task0 setting task1's new affinity. \n", Core_getId());
    oldAffinity = Task_setAffinity(tsk1, newCoreId);
    if(newCoreId == oldAffinity) {
        System_printf("Task_setAffinity failed for task %u \n", !arg0);
        UART_printf("Task_setAffinity failed for task %u \n", !arg0);
        BIOS_exit(0);
    }

    System_printf ("Core%u: Task0 running again. \n", Core_getId());

    while (!tsk1Done);
    tsk0Done = TRUE;
}

Void myTask1(UArg arg0, UArg a1)
{
    UInt newCoreId = arg0, oldAffinity;

    while (Core_getId() != 0);
    System_printf ("Core%u: Task1 setting task0's new affinity. \n", Core_getId());
    UART_printf("Core%u: Task1 setting task0's new affinity. \n", Core_getId());
    //Log_print0("Core%u: Task1 setting task0's new affinity. \n", Core_getId());

    oldAffinity = Task_setAffinity(tsk0, newCoreId);
    if(newCoreId == oldAffinity) {
        System_printf("Task_setAffinity failed for task %u \n", !arg0);
        UART_printf("Task_setAffinity failed for task %u \n", !arg0);
        BIOS_exit(0);
    }

    tsk1Done = TRUE;
}
/*
 *  ======== main ========
 */
Int main()
{ 
    /* Call board init functions */
    Board_initCfg boardCfg;

    boardCfg =  BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_UART_STDIO;
#if defined (SOC_AM574x) && defined(NIMU_DUAL_MAC_MODE)
    boardCfg |= BOARD_INIT_ETH_PHY;
#endif
    Board_init(boardCfg);

    Error_Block eb;
    Task_Params tskParams;
    System_printf("enter main()\n");
    UART_printf("\n main \n");

    Error_init(&eb);
    Task_Params_init(&tskParams);
    tskParams.priority = 2;
    tskParams.arg0 = 0;
    tskParams.affinity = 0;
    tsk0 = Task_create(myTask0, &tskParams, &eb);
    if (tsk0 == NULL) {
        System_printf("Task0_create() failed!\n");
        BIOS_exit(0);
    }

    tskParams.priority = 3;
    tskParams.arg0 = 1;
    tskParams.affinity = 1;
    tsk1 = Task_create(myTask1, &tskParams, &eb);
    if (tsk1 == NULL) {
        System_printf("Task1_create() failed!\n");
        BIOS_exit(0);
    }

    BIOS_start();    /* does not return */
    return(0);
}