什么是抢占式多任务处理?
什么是抢占式多任务处理?谷歌搜索后我找不到答案有人可以帮助我吗?
What is preemptive multitasking? After googling it I couldn't find an answer can someone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
http://en.wikipedia.org/wiki/Preemption_(computing)
阅读维基百科文章。可以这样想,它是一种允许您同时运行许多不同程序的方法,而无需编写每个程序来放弃处理器的时间 - 操作系统会处理它。这个想法是每个进程在某个时刻都被“抢占”。
http://en.wikipedia.org/wiki/Preemption_(computing)
Read the Wikipedia article. Think of it this way, it is a way to allow you to run many different programs at once without each program needing to have been written to give up the processor's time - the OS handles it. The idea is that each process is "preempted" at some point.
简而言之,如果一个进程是抢占式的,那么它可以通过外部中断(陷阱)停止并发送到就绪队列。
对于情况 1 和 4,存在非抢占式
simply if a process is a preemptive then it can be stopped and send to ready queue by external interruption(trap).
For situations 1 and 4,there is not-preemptive
抢占式多任务处理需要两个主要组件:计时器中断(例如每 10 毫秒一次)和“连接”到该中断的调度程序。然后,调度程序将“中断/抢占”任务的“上下文”(这是所有寄存器/堆栈指针的奇特术语)保存在某个区域(如堆栈),然后通过其调度算法确定哪个(其他)任务可以“运行”接下来。
如果找到一个,它会展开/恢复该任务的上下文并从计时器中断中返回。顺便说一句,就像“调用”将返回地址(通常是调用指令之后的地址放在堆栈上)一样,中断也以相同的方式工作,当中断“返回”时,它使用堆栈上的内容并跳转到该地址。因此,当我们从其他任务返回到其“中断”点时,我们只需操作堆栈,并将该任务的返回地址放在堆栈的顶部,并执行与“Return-from_Interrupt”指令不同的指令。正常退货。我打赌你现在很抱歉你问了这个问题!
干杯,
Preemptive Multitasking requires two main components: A timer interrupt ( say every 10 msec ) and a scheduler which is 'Connected' to that interrupt. The scheduler then saves the 'context' of the "interrupted/preempted" task ( which is fancy term for all the registers/stack pointer) in some area ( like stack) and then determines via its scheduling algorithm which ( other) task can "run" next.
If it finds one, it unwinds/restores the context for THAT task and returns from the timer interrupt. BTW, just like a "call" which places the return address ( usually the address after the Call instruction on the stack, an interrupt works the same way and when an interrupt "returns" it uses what is on the stack an jumps to it. So when we're returning from some other task to its 'interrupt' point we just have to manipulate the stack, and place the return address from THAT task on the TOP of the stack and do an "Return-from_Interrupt" instruction. Different from normal return. I bet you're now sorry you asked !
Cheers,