禁用中断会自动禁用CPU调度吗?
大家好,如果禁用中断,是不是所有进程/线程调度都会被禁用?据我所知中断包括时钟中断和其他中断。 CPU 调度(例如,循环)基于时钟中断。如果禁用该选项,则调度也会被禁用,并且当前线程将继续执行,直到产生 CPU。如果我错了,请纠正我。
如果是纯基于优先级的调度而不是RR(考虑实时系统),并且较低优先级的线程禁用了中断,那么较高优先级的线程到达,较低优先级的线程会被抢占吗?
这让我想到了操作系统的保护。如果某些用户故意编写病毒来禁用中断怎么办?也许他不能在用户模式下做到这一点,如果他编写一个在内核模式下运行的程序并做了那些坏事怎么办?他能做到吗?
我并不期望所有平台都有通用规则。所以请您告知一下您知道的平台情况如何,谢谢。
Hey guys, is it true that all the process/thread scheduling will be disabled if interrupt is disabled? What I know is interrupt includes clock interrupt and other interrupts. CPU scheduling(e.g., Round-Robin) is based on clock interrupt. If that's disabled, scheduling is disabled as well and the current thread continues executing until it yeilds CPU. Please correct me if I'm wrong.
If it's pure priority-based scheduling instead of RR (considering real-time systems), and a lower priority thread disables the interrupt, then a higher priority thread arrives, will the lower priority thread be preempted?
This leads me to think about the protection in operating system. What if some user intentionally write a virus to disable interrupts? Probably he cannot do that in user mode, what if he writes a program running in kernal mode and does that bad stuff? Can he do this?
I'm not expecting a general rule across all platforms. So please let me know what the situation is on the platform you know, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,您问题的答案取决于架构。假设我们正在谈论 i386 或 x86_64,因为它们是当今最流行的处理器架构。
用户模式程序无法清除中断标志,因为它需要 CPL(当前权限级别)0。用户模式程序永远不会有 CPL 0。例如,在 Linux 中,用户模式程序以 CPL 2 运行,只有内核以 CPL 0 运行。因此你不能编写一个病毒来禁用中断,从而禁用调度。在 Windows 中,如果我没记错的话,程序使用 CPL 1 运行。
另一方面,在内核中运行代码(在任何操作系统中)需要管理权限,这允许你做任何你想做的事情,所以在内核模式下禁用中断没有任何意义。
希望这能回答您的问题。
Actually, answer to your question is architecture dependant. Let us assume that we are talking about i386 or x86_64 as these are the most popular processor architectures these days.
User-mode program cannot clear interrupt flag because it requires CPL (current priviledge level) 0. User-mode programs never have CPL 0. In Linux for example, user-mode programs run with CPL 2 and only kernel runs with CPL 0. Therefore you cannot write a virus that would disable interrupts and thus disable scheduling. In Windows, if I am not mistaken, programs run with CPL 1.
On the other hand running code in kernel (in just any operating system) requires administrative rights, which allow you to do anything you want anyway, so disabling interrupts in kernel mode doesn't make any sense.
Hope this answers your question.