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: Task_delete() error handling

Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I would like to know more details about error handling (Error_Block) in TI-RTOS.

I need to write a graceful exit in one of my application. My application is running with multiple tasks and for graceful exit I am calling Task_delete() of one task from another task by passing its handler . Since its  not return any values, how we can confirm that Task_delete() was successful? Does Error_Block can be used for that or any other mechanism is there?

Regards,

Sandhya

  • Hi Sandhya,

    Task_delete cannot fail, so there is no return code. Having said that, if you pass in some random address as the Task_Handle (instead of a valid Task_Handle), that will probably cause a problem, but the API could not have checked for that anyway. We do have some asserts in Task_delete. These are more design checks as opposed to run-time checks. I would perform the bulk of my development and testing with asserts enabled and then disable them (if desired) near the end.

    Error_Blocks would not be useful with Task_delete since it does not take an Error_Block parameter.
    Todd
  • Thank you very much for your  reply. I would like to know more details about error handling. Is there any way to identify the particular error codes and its mapping ? For example, while creating tasks it can fail  due to multiple reasons like parameter issues or memory issues ect. How these errors can be identified using error block?

  • Sadnhya,

    the complete Error documentation is at rtsc.eclipse.org/.../Error.html

    The function Error_print(Error_Block *eb) will print the error message if you are using CCS and the debugger. If you are looking for programmatic examination of a raised error, here is an example of generic error checking. Task_create does not generate Error_Ids that I am using in this example, I am just giving an overview of how Error_Ids are used:

    #include <xdc/runtime/Error.h>

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

    Error_Block eb;

    Task_Handle tsk;

    Error_init(&eb);

    tsk = Task_create(..., &eb);

    if (Error_check(&eb)) {

       Error_Id eid = Error_getId(eb);

       if (eid == Error_E_generic) {

           ... do one thing

       }

       else if (eid == E_stackOverflow) {

           ... do another thing

       }

    }

  • Hi,

    Thanks for the details. I need one more info about the error handling. For a particular API, say Task_create(), what are the possible error Ids (like E_stackOverflow) it can return ? Is it available in any of the TI documentation or in any header files?

    Regards,

    Sandhya

  • Each module's xdc file should contain errors and asserts that can be raised under various conditions.
    However looking at the source code of Task.c, which is available in all SYS/BIOS 6 releases, I can see that the error block is not used and if Task_create fails, an app will terminate. So, the error handling mechanism is available for modules to use but it is not a requirement.
  • Can I mark this thread as resolved?
  • Okay.
    I am writing an abstraction layer for RTOS calls and my intension is to categorize the type of errors, which can happen when an API (Eg:Task_create)is called. This is required for the application to log it or take some actions based on type of error it returns. So if you can provide more inputs on this it would be helpful.
  • Currently Task_create can return the following errors
    - Error_E_memory (or xdc_runtime_Error_E_memory if you prefer the longer name). This is done in the generated Task_create call.
    - Any errors raised in the Task create hook functions.

    If you wanted more possible errors from the different APIs, I'd look at the source code and look for the Error_raise.

    Todd
  • Thanks Todd...