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/CC2640: Task_delete causes exception

Part Number: CC2640


Tool/software: TI-RTOS

I am trying to delete a task with Task_delete. This raises an exception and the program seems to be stuck in xdc_runtime_Error_policySpin__E. 

I have added Task_setPri(-1) before the delete, but that doesn't fix the issue. I have attached the call stack as well as disassembly.

#define SERVO_TASK_STACK_SIZE 480
Char servoTaskStack[SERVO_TASK_STACK_SIZE];
Task_Handle servoTaskHandle;

void createServoTask() {
    
  Task_Params taskParams;

  Task_Params_init(&taskParams);
  taskParams.stack = servoTaskStack;
  taskParams.stackSize = SERVO_TASK_STACK_SIZE;
  taskParams.priority = 5;
  
  servoTaskHandle = Task_create(taskFuncServo, &taskParams, NULL);
}

void deleteServoTask() {
    if (servoTaskHandle) {
        Task_setPri(servoTaskHandle, -1);
        Task_delete(&servoTaskHandle);
    }
}

  • Hi,

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

    • 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.

    Thanks,
    Gerardo

  • There was a suggested answer and since there has been no active on this thread for more than a week, the suggested answer was marked as verify. Please feel free to select the "Reject Answer" button and reply with more details.