Ref: synchronizing init task with an arbitrary number of worker tasks

Andrei Chichak groups at
Wed Sep 26 04:44:36 UTC 2012

On 2012-September-25, at 4:30 PM, Andrei Dimitrief-Jianu wrote:

> Hello,
> I have an arbitrary number of worker tasks created and started in the
> init task. I would like to have the init task wait on all of them to
> finish and perform an exit() afterwards.

When I am dealing with a bunch of tasks and I must be certain that they run, I use a set of global variables, one per task, the mainline sets the variables to one value and when the tasks finish their processing they set their variable to another value. The mainline then gives the tasks a reasonable amount of time to do their job then tests that the variables have changed. An unchanged variable indicates a task that has not finished.

Another method is to have each of the tasks send a message to the mainline upon swift completion of their appointed rounds. The mainline then has the chore of keeping track of who has checked in and who hasn't.

These methods may seem simplistic, but they are portable to other RTOS' that don't have a plethora of facilities.


More information about the users mailing list