How can I explicitly perform a task switch?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How can I explicitly perform a task switch?

跳至解决方案
1,177 次查看
panpwr
Contributor IV

I have few tasks run in parallel, and I want to let the MQX OS manage the task queue according to task's priorities, without my interference.

Thus, I do not want task A to block itself (by using _task_block), come back to life only when  Task B will set it ready (by using _task_ready).

Currently, when I wish to switch tasks, I use _time_delay(1) - which is pretty bad programming practice, since this task will wake up after a whole millisecond at the minimum, and not when it is needed.

    

So, How can I explicitly perform a task switch?

Thanks,

Lior.

标记 (3)
0 项奖励
回复
1 解答
891 次查看
Martin_
NXP Employee
NXP Employee

Hi Lior,

With FIFO scheduling, the active task runs, until any of the following occurs:

-the active task voluntarily relinquishes the processor, because it calls a blocking MQX function
-an interrupt occurs that has higher priority than the active task
-a task that has priority higher than the active task, becomes ready


There exists _time_delay_ticks() function which gets parameter in minimum number of ticks to suspend the task.


MQX supports also Round Robin scheduling, which is similar to FIFO scheduling, but with the additional constraint that each round robin task has a maximum amount of time (the time slice), during which it can be active. When the time slice expires, the MQX then performs a dispatch operation to determine, which task should become active.

在原帖中查看解决方案

0 项奖励
回复
1 回复
892 次查看
Martin_
NXP Employee
NXP Employee

Hi Lior,

With FIFO scheduling, the active task runs, until any of the following occurs:

-the active task voluntarily relinquishes the processor, because it calls a blocking MQX function
-an interrupt occurs that has higher priority than the active task
-a task that has priority higher than the active task, becomes ready


There exists _time_delay_ticks() function which gets parameter in minimum number of ticks to suspend the task.


MQX supports also Round Robin scheduling, which is similar to FIFO scheduling, but with the additional constraint that each round robin task has a maximum amount of time (the time slice), during which it can be active. When the time slice expires, the MQX then performs a dispatch operation to determine, which task should become active.

0 项奖励
回复