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/CC2650: How Start and Stop thread

Part Number: CC2650
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello

I want create a thread for blink led.

i execute this code :

void vd_app_BlinkChoose_createTask(void)
{
Task_Params taskParams;

// Configure task
Task_Params_init(&taskParams);
taskParams.stack = u8_AppChooseBlinkTaskStack;
taskParams.stackSize = APP_CHOOSE_TASK_STACK_SIZE;
taskParams.priority = 1;

TaskBlink = Task_create(&vd_app_choose_blink_taskFxn, &taskParams,NULL);
}

for stop the thread i execute this code : Task_delete(&TaskBlink);.

But my software fall in runtime error. 

i already execute Task_exit(); in my blink thread before execute Task_delete but nothing works.

can you explain me how start and stop and restart ...etc a thread.

Thanks

  • Hi,

    I can think of a few reasons why this could be happening:

    • Task_delete() may be being called from interrupt context, which is not allowed.
    • Automatic deletion of terminated Tasks may be enabled, in which case the application code is not allowed to delete Tasks.
    • The current running task is what's calling Task_delete(), which is not allowed.

    If automatic deletion is enabled, the task will be automatically deleted if you call Task_exit().

    Thanks,
    Gerardo

  • Hello

    I don't call Task_delete() from interrupt context.

    I don't call Task_delete() from the task to be deleted.

    I activate the Automatic deletion of terminated Tasks and delete the call of Task_delete(). Just call Task_exit from the task to be deleted.

    i have the same problem.  in my Disassembly windows i can see that my code is stopped "xdc_runtime_Error_policySpin__E: 0x2848: 0xE7FE ....."

    Thanks

  • Hi,

    Have you looked in the ROV (under the tools menu) to see if any errors were detected?
    Look in BIOS -> Scan for errors
    And look also under Tasks.

    Another thing, have you look at the call stack or debug window to see which line of code caused the problem.
    Your debugger needs to be paused. You can attach screenshots of any error messages or windows which might help us figure out what the problem is.

    I suggest that you disable the automatic deletion and place your Task_delete back into your code. You must also leave the Task_exit for the delete to work.

    Let us know what you find.

    Regards,
    Michel
  • Hello

    I don't find the ROV. I work on IAR.

    I disable Task.deleteTerminatedTasks and i execute  Task_delete(&TaskBlink) after Task_exit() from a another task

    but the problem is still.

    attache my c file and screenshot

    Best reagards

    7181.app_choose.c

  • I know that ROV is available for IAR, however, I do not know how to add it to IAR projects. Maybe somebody from TI could help you with that.

    Can you attach a screenshot of the CallStack? (you can open the call stack from the View menu)

    Also, can you check what Task_getMode(...) returns if you call it from just before you attempt to delete the task? Below is the prototype of the function:

    Task_Mode Task_getMode(Task_Handle handle);

    The possible return values:

    typedef enum Task_Mode {
        Task_Mode_RUNNING,
        // Task is currently executing
        Task_Mode_READY,
        // Task is scheduled for execution
        Task_Mode_BLOCKED,
        // Task is suspended from execution
        Task_Mode_TERMINATED,
        // Task is terminated from execution
        Task_Mode_INACTIVE
        // Task is on inactive task list
    } Task_Mode;


    Regards,

    Michel

  • 1. Right click your project and select "Options...".

    2. Select "Debugger" from the left menu. Go to the "Plugins" tab and scroll down until you see the item, "TI-RTOS". Make sure the checkbox is selected.

    3. Select the "TI-RTOS" menu item while connected through the debugger.

    Derrick

  • Hello

    For delete the task i use this code.

    void vd_app_BlinkChoose_deleteTask(void)
    {
    u8_Blink = false;

    while(Task_getMode(TaskBlink) != Task_Mode_TERMINATED)
    {
    Task_sleep(((100) * 1000) / Clock_tickPeriod);
    }

    Task_delete(&TaskBlink);
    }

    But the problem persists

    attached iar windows

    Thanks

  • maybe i have a problem when i create the task.

    can you tell me if my code is true?

     Task_Params taskParams;
      Error_Block eb;
    
      // Configure task
      Task_Params_init(&taskParams);
      Error_init(&eb);
      taskParams.instance->name = "blink";
      taskParams.stack = u8_AppChooseBlinkTaskStack;
      taskParams.stackSize = APP_CHOOSE_TASK_STACK_SIZE;
      taskParams.priority = 1;
      
      TaskBlink = Task_create(&vd_app_choose_blink_taskFxn, &taskParams,&eb);

    Best regards

  • If this can help i join my file app_ble.cfg

    Thanks

    3531.app_ble.cfg

  • Hello,

    Could you try changing the following setting on line 688 of your .cfg file to true:

    Task.deleteTerminatedTasks = Bool true;

    SYSBIOS will automatically delete a Task after Task_exit() is called.

    Note: If this feature is enabled, an Idle function is installed that deletes dynamically created Tasks that have terminated either by falling through their task function or by explicitly calling Task_exit(). When this feature is enabled, an error will be raised if the user's application attempts to delete a terminated task. If a terminated task has already been automatically deleted and THEN the user's application attempts to delete it (ie: using a stale Task handle), the results are undefined and probably catastrophic!

  • Hello

    Unfortunately i already realize this test.
    But the problem persists

    do you have other ideas.

    Thank you
  • You are using HeapMin for your memory management (in the .cfg file that you posted previously). I just looked at the SYSBIOS user guide and I found this:

    HeapMin is a minimal footprint heap implementation. This module is designed for applications that generally allocate memory and create module instances at runtime, but never delete created instances or free memory explicitly.

    HeapMin does not support freeing memory. By default, an application aborts with an error status if it calls HeapMin_free().

    Not sure whether this is the cause of the problem, but worth a try. Look in the SYSBIOS user guide memory management section to see which heap will suit your needs best.

    Regads,

    Michel

  • In addition to Michel's suggestion, I suggest your application double check your Task handles.

    Before calling Task_exit(), I suggest setting the Task Handle to NULL.
    Before calling Task_delete(), I suggest checking if the Task Handle is not NULL.

    Derrick

  • Hello

    thanks I test this in the next week.
    I'll keep you informed.

    Best regards