调度程序在需要时如何重新获得控制权? [英] How does a scheduler regain control when wanted?

查看:222
本文介绍了调度程序在需要时如何重新获得控制权?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读有关调度的信息,但是我无法弄清楚调度程序在用户空间中调用代码后如何重新获得控制权.

I'm reading about scheduling, but I can't figure out how a scheduler regains control after it invokes code in the user space.

例如调度程序将控件传递给用户空间中的某个应用程序,该应用程序执行无限循环,并且一个核心芯片上没有其他硬件中断发生.所有文档都讨论了调度程序重新获得控制权并抢先中断用户进程的方法,但是,如果控制权从未传递回操作系统,那该怎么办?

E.g. the scheduler passes the control to some app in the user space which does some infinite loop and no other hardware interrupt occurs on an one core chip. All documents talk about the scheduler regaining control and preemptivly interrupting the user process, but how does that work if the control is never passed back to the OS?

问题::调度程序是否在X毫秒后向CPU中的某个时钟注册以再次获得控制权?还是还有其他技巧?如果不是,则调用 C函数进行注册以重新获得常规(或一次?)控制权是什么?

Question: Does the scheduler register with some clock in the CPU to be given control again after X msecs? Or is there some other trick? If no, what is the C function called to register for regular (or one time?) control regains?

推荐答案

如果没有其他中断发生,抢先的O/S将不会发送,并且用户应用程序将永远循环.

If no other interrupt occured, a preemptive O/S wouldn't despatch, and the user application would loop for ever.

这不会发生.通常,抢占式调度程序将在每个系统调用,每个中断和系统时钟的每个滴答声中分派.系统时钟将始终中断,因此不会发生无限循环.

This won't happen, though. Typically, a preemptive scheduler will despatch on every system call, every interrupt, and every tick of the system clock. The system clock will always interrupt, so your infinite loop simply won't occur.

Pick操作系统(在其开发人员Dick Pick之后)使用了非抢先式调度程序.需要为此系统开发的软件定期进行系统调用,以允许内核调度其他进程.在这种环境下,内核将完全失去控制,直到进程终止.

The Pick operating system (after its developer Dick Pick) used a non-preemptive scheduler. Software developed for this system was required to make a system call periodically to allow the kernel to despatch other processes. In this environment the kernel would otherwise lose control completely until the process terminated.

其辩解中使用的论据是,在派遣期间花费了大量时间来保存和恢复处理器状态.强制应用程序为此承担责任将允许更快的发送过程.

The argument used in its justification was that considerable time was spent saving and restoring the processor state during a despatch. Forcing the application to take responsibility for this would allow a faster despatch process.

这篇关于调度程序在需要时如何重新获得控制权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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