什么是抢占式多任务处理?

发布于 2024-09-29 09:46:42 字数 39 浏览 0 评论 0原文

什么是抢占式多任务处理?谷歌搜索后我找不到答案有人可以帮助我吗?

What is preemptive multitasking? After googling it I couldn't find an answer can someone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无人问我粥可暖 2024-10-06 09:46:42

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.

风吹雨成花 2024-10-06 09:46:42

简而言之,如果一个进程是抢占式的,那么它可以通过外部中断(陷阱)停止并发送到就绪队列。

  1. 当进程从运行状态切换到等待状态时(例如,由于 I/O 请求或调用 wait() 来终止子进程)
  2. 当进程从运行状态切换到等待状态时就绪状态(例如,发生中断时)
  3. 当进程从等待状态切换到就绪状态时(例如,I/O 完成时)
  4. 当进程终止时

对于情况 1 和 4,存在非抢占式

simply if a process is a preemptive then it can be stopped and send to ready queue by external interruption(trap).

  1. When a process switches from the running state to the waiting state (for example, as the result of an I/O request or an invocation of wait() for the termination of a child process)
  2. When a process switches from the running state to the ready state (for example, when an interrupt occurs)
  3. When a process switches from the waiting state to the ready state (for example, at completion of I/O)
  4. When a process terminates

For situations 1 and 4,there is not-preemptive

烟沫凡尘 2024-10-06 09:46:42

抢占式多任务处理需要两个主要组件:计时器中断(例如每 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,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文