This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Switching a task

can somebody kindly give me a good explanation on usage of "os_tsk_pass()".
i really dont know why i cant find a valid method to pass the execution to a task of lower priority.

cant use os_evt_wait_or, because it sets event for only a specific task.

i have this scenario, of regulating the speed of motor. so regulating routine is one task. and there are two other tasks (out of which only one is in the scheduler at any given time). when created and started, both tasks wait for speed regulation. implementation of such a algorithm becomes difficult and i have to specifically check for which task is running and then generate an event accordingly. what a messy situation. stupidly check the global flags and generate events hence increase the number of global flags.

Parents
  • The way to switch to a lower priority task?

    Two alternatives
    1) Have the lower-prio task wait for an event, and send such an event and then sleep. If that leaves the lower-prio task as the highest-prio task ready to run it will.

    2) Have the lower-prio task just round-robin (maybe using timers to wake up and run for a bit every x clock ticks), waiting until all higher-priority tasks are sleeping.

    If you want to explicitly "call" a lower-priority task, then you are programming as if the tasks was functions. They aren't, and the OS is designed to give time to the highest-priority task ready to run. That is one of the main goals of an RTOS. So it is up to you to decide priorities for the tasks, and arrange the situation so the individual tasks can become the highest-prioritized ready-to-run task when so is required.

    I don't see why your two "worker tasks" should behave as if they were consumers that should run in lock-step with the regulation. It would be normal for them to just be able to check some state information "in sync" or "not in sync". So as soon as the motor has spun up and reached stable speed, it's in sync and the tasks can do whatever they want until there is some issue that makes the motor no longer be able to uphold the required speed.

Reply
  • The way to switch to a lower priority task?

    Two alternatives
    1) Have the lower-prio task wait for an event, and send such an event and then sleep. If that leaves the lower-prio task as the highest-prio task ready to run it will.

    2) Have the lower-prio task just round-robin (maybe using timers to wake up and run for a bit every x clock ticks), waiting until all higher-priority tasks are sleeping.

    If you want to explicitly "call" a lower-priority task, then you are programming as if the tasks was functions. They aren't, and the OS is designed to give time to the highest-priority task ready to run. That is one of the main goals of an RTOS. So it is up to you to decide priorities for the tasks, and arrange the situation so the individual tasks can become the highest-prioritized ready-to-run task when so is required.

    I don't see why your two "worker tasks" should behave as if they were consumers that should run in lock-step with the regulation. It would be normal for them to just be able to check some state information "in sync" or "not in sync". So as soon as the motor has spun up and reached stable speed, it's in sync and the tasks can do whatever they want until there is some issue that makes the motor no longer be able to uphold the required speed.

Children
No data