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.

SYS/BIOS TASK.C QUESTION

OUr customer has the following question regarding SYS/BIOS

A colleague and I are looking into the RTOS critical region functions such as Task_disable() and Task_enable() as part of our use of the RTOS logging facility to help us capture critical timing events and stumbled onto something looking at the source code in Task.c that has us confused.  We assume that those functions are working and there are no bugs but it seems that the code sets a Boolean to lock the task thus preventing a context switch but the weird thing is that it doesn’t look like it checks the lock before it schedules the next ready task. 

Can you shed any light on what we’re seeing?

Thanks for your help!

Regards,

John Wiemeyer

  • Hi John,

    Task_disable() function stops other tasks from running and returns a key.  To allow other tasks once more, the Task_restore() function should be used (using the key as a parameter).  The key is required to ensure that Task scheduling is not enabled until there has been a Task_restore(key) for all previous Task_disable() calls.

    Also please keep in mind that while Tasks are disabled, HWI's and SWI's are still enabled.  If you want to benchmark code, you should wrap your critical sections in HWI/SWI_disable() and HWI/SWI_enable().

    Task_enable unconditionally enables the Task scheduler.  It is called by BIOS_start to begin multi-tasking.  This function should not be used in application code.

    Hope this helps clear things up.

    -- Emmanuel

  • Thanks Emmanuel.

    Regards,

    John