Menu

#124 Task creation and run time management

closed
nobody
5
2020-02-24
2019-02-26
Tom Barclay
No

I would like to request that the task Create methods have an additional boolean parameter to allow the task to be placed on the ready list , bool= TRUE (as happens now) or on the suspended list, bool= FALSE.

I believe my problem is a common one in that my application architecture splits the tasks in to three groups.

Support tasks - create at boot time, before scheduler is active , Immediately suspend them after
creation
(These are typically i/o and interface tasks as well as debug and monitoring tasks),

Supervisor task - create at boot, dont suspend, it will run as soon as the scheduler is started.
(this task starts up the support tasks in order, then creates and starts the
mode specific application tasks)

Application Tasks - create (and destroy) within the Supervisor. Started by the supervisor in desired
order.
(They are modal, so different operating modes will require different collections of
tasks to be active at runtime.)

The creation of the Application tasks is where the problem lies ... the current task create method immediately put the tasks on the ready list, so they can execute immediately after creation as the scheduler is active. This causes potential application race conditions.

A work around is to create them with a low priority and suspend them immediately after creation.
Then whilst suspended set the desired runtime priority. The supervisor can then start and stop them in the required order for stable operation.

This seems to work, but is not a perfect solution.

Discussion

  • Richard Barry

    Richard Barry - 2020-02-24
    • status: open --> closed
     
  • Richard Barry

    Richard Barry - 2020-02-24

    As there is a workaround already I prefer not to break backward compatibility by changing the xTaskCreate[static}() API. It could be achieved without breaking the API by overloading a bit in an existing API parameter - as per the 'create priviliged' bit used in the MPU port, but that is a bit hacky.

     

Log in to post a comment.