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.

Task Hook Causes System Exit

Other Parts Discussed in Thread: TM4C1294NCPDT, SYSBIOS

Hello,


I'm trying to add a hook for when a task exits.  I've added the following code to the bottom of my config file:

Task.addHookSet({
    exitFxn: '&myExit'
});

My code compiles fine but immediately goes to loader_exit when I start it.  If I comment out the addHookSet(), my program executes normally.  What could cause this crash?  Are there other specific settings needed within BIOS to enable the use of task hooks?

Thanks,

Eric

  • Eric,
    can you set up a breakpoint in the function 'myExit'? Normally, you would see that function invoked for each task, and your call stack should show myExit being invoked from a task's function.
    Can you also check if your tasks' functions are called at all?
  • Hi Sasha,

    Actually, my code does it get that far. When BIOS_start() is called within main(); the code exits.

    Thanks,
    Eric
  • Which device is this? Can you share your entire .cfg file? Does the ROV BIOS "Scan for errors..." view give any hint to what the problem is?
  • I can't see any obvious reason why adding hooks would change the behavior of your app. Are your tasks created statically or dynamically?
    You can try going into BIOS_start and see how far the app goes before exiting. That might offer some clues. You could also post your project so I can try to replicate it.
  • I'm using a TIVA TM4C1294NCPDT running RTOS 2.16 and SYSBIOS 6.45 within CCS 6.2. 


    I am creating tasks statically, but I will also create additional ones dynamically. 


    How can I set breakpoints/step through BIOS_start()?  I tried to follow the code to get to the source, but I wasn't successful.  I would like to know how to do this.

    Eric

  • If I understand your earlier posts correctly, you already have breakpoints at the beginning of each of your task functions, and in myExit. If not, please add them. Then, add a breakpoint to BIOS_start, and then step into that function, and after a couple of steps you should end up in ti_sysbios_BIOS_startFunc__I. Then, add a breakpoint to a call to ti_sysbios_knl_Task_startup, and see if you reach that when you let the program run. Then, step into that function and keep stepping deeper until you get to Task_startCore. Once in that function, keep stepping over the function calls in that function. Let me know how it goes, and where in these steps your app goes to exit.
  • Well, if I did this correctly, the last line of code I'm able to execute is within "Hwi_asm_switch.sv7m. Single step execution lands at the push {lr}. I get here after a good number of step overs within Task_startCore.

    ; ======== ti_sysbios_family_arm_m3_Hwi_initStacks__E ========
    ; set up dual stacks
    ; only called if tasking is enabled
    ; otherwise, msp = the only stack.
    ; msp = handlers (isr Stack)
    ; psp = threads (task Stacks)
    ;
    ti_sysbios_family_arm_m3_Hwi_initStacks__E:
    .asmfunc
    push {lr}
    mrs r2, xpsr
    tst r2, #0xff ; check if we're in handler mode
    beq $1

    I'm unable to step further at this point - those functions are actually grayed out. If I hit run from here, I end up in exit.
  • Are you looking at the assembly code in the Disassembly window? You should be able to execute these instructions one by one in the Disassembly window and find out which one doesn't return. I am not sure what's being grayed out. Can you post a screenshot? If you can, include core registers window in the screenshot.
    I am not really sure how would that code be impacted only by adding a hook set at the config time. I'll have to ask someone else from the TI-RTOS team for help.
  • I think I found the source of the problem.  When I include the hook to "myExit" within my config file, myExit function executes during BIOS startup.  The code within myExit is a simple Task_delete(handle) command.  But, the task which should be deleted hasn't been started yet.  This task (autopH) is one that gets dynamically created later. 

    My plan is to enable the user to start and stop the autopH task.  When prompted by the user, autopH will exit and I would like to enable the exit hook to call myExit so I can delete the task.  That way, a user can recreate the task if necessary through appropriate input. 

    Why does myExit run during BIOS start?  I don't think if it as a task, more as a callback when Task_exit() is called.  Is there anyway to prevent it from running?

    Thanks,

    Eric

  • BIOS_start() doesn't return so technically every task runs and exits during BIOS_start(). When and where are you creating 'autopH' task?
    The exit hook is called after a task's function ends or as a consequence of explicitly calling Task_exit() for a task. In both cases, the handle to that task is passed to the exit hook function. It doesn't seem possible that a handle for a task that is not being created yet ends as a parameter to the exit hook function.
    Also, read carefully through the documentation for Task_delete. Task_delete() sets the handle passed to it to NULL. It sounds like you are reusing a Task Handle so you have to be careful not to reference any Task instance function until the handle points to a new Task instance.
  • Ah, I now know the problem. I thought the exit hook would only be called by an explicit Task_exit(). Your comment above about when a task's function ends directed me to the real issue. I am creating a couple static tasks which currently don't have any code in them. I just haven't gotten around to completing that part of my software. If I understand correctly, these tasks will get started and automatically terminate, thus calling the exit hook. Since I thought the exit hook would only be called by Task_exit(), the code in myExit is not setup for a generic task terminate call and tries to delete a task which hasn't been created yet, causing the system crash.

    Thanks for your help!
    Eric
  • Good we got to the bottom of it. Please mark the thread as answered.