VxWorks 调度程序如何执行? [英] How does a VxWorks scheduler get executed?

查看:50
本文介绍了VxWorks 调度程序如何执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道如何调用调度程序以便它可以切换任务.就像即使是抢占式调度或循环调度一样 - 调度程序应该参与进来以进行任何类型的任务切换.假设一个低优先级的任务有一个无限循环——调度器什么时候介入并切换到一个更高优先级的任务?

Would like to know how the scheduler gets called so that it can switch tasks. As in even if its preemptive scheduling or round robin scheduling - the scheduler should come in to picture to do any kind of task switching. Supposing a low priority task has an infinite loop - when does the scheduler intervene and switch to a higher priority task?

查询是:1. 谁调用调度程序?[在 VxWorks 中]2. 如果它被定期调用 - 该机制是如何实现的?

Query is: 1. Who calls the scheduler? [in VxWorks] 2. If it gets called at regular intervals - how is that mechanism implemented?

提前致谢.

--阿什温

推荐答案

简单的答案是 vxWorks 通过来自系统计时器的硬件中断进行控制,该中断在系统运行时以固定间隔持续发生.

The simple answer is that vxWorks takes control through a hardware interrupt from the system timer that occurs continually at fixed intervals while the system is running.

这里有更多细节:

当 vxWorks 启动时,它会配置您的硬件以生成一个计时器 interruptn 毫秒,其中 n 通常为 10,但完全取决于您的硬件.计时器间隔通常由 vxWorks 在您的 Board Support Package (BSP) 启动时设置.

When vxWorks starts, it configures your hardware to generate a timer interrupt every n milliseconds, where n is often 10 but completely depends on your hardware. The timer interval is generally set up by vxWorks in your Board Support Package (BSP) when it starts.

每当计时器触发中断时,系统就会开始执行计时器中断处理程序.定时器中断处理程序是 vxWorks 的一部分,所以现在 vxWorks 有控制权.它做的第一件事是将 CPU 状态(例如寄存器)保存到 当前运行任务的任务控制块 (TCB).

Every time the timer fires an interrupt, the system starts executing the timer interrupt handler. The timer interrupt handler is part of vxWorks, so now vxWorks has control. The first thing it does is save the CPU state (such as registers) into the Task Control Block (TCB) of the currently running task.

然后最终 vxWorks 运行调度程序以确定下一个运行的人.为了运行一个任务,vxWorks 将任务的状态从它的 TCB 复制到机器寄存器中,然后任务就可以控制 CPU.

Then eventually vxWorks runs the scheduler to determine who runs next. To run a task, vxWorks copies the state of the task from its TCB into the machine registers, and after it does that the task has control of the CPU.

奖金信息:

vxWorks 提供 hooks任务切换逻辑,这样你就可以在任务被抢占时调用一个函数.

vxWorks provides hooks into the task switching logic so you can have a function get called whenever your task gets preempted.

这篇关于VxWorks 调度程序如何执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆