简体   繁体   English

在linux和unix情况下,为什么在处理中断的方式上有设计上的区别?

[英]Why is there a design difference between the way interrupts are serviced in case of linux and unix?

In the book The Design of the Unix Operating System by Maurice it is mentioned that interrupts are serviced in the context of the running process as it doesn't spawns a new process to service interrupts. 在Maurice撰写的《 Unix操作系统的设计》一书中,提到中断是在正在运行的进程的上下文中提供的,因为它不会产生新的进程来处理中断。

So, in Unix a processor is doing exactly one of the two things: 1. In user-space, executing user code in a process 2. In kernel-space, in process context, executing on behalf of a specific process. 因此,在Unix中,处理器正是在执行以下两项操作之一:1.在用户空间中,在进程中执行用户代码2.在内核空间中,在进程上下文中,代表特定进程执行。

But, in many operating systems, including Linux, the interrupt handlers do not run in a process context. 但是,在包括Linux在内的许多操作系统中,中断处理程序不会在进程上下文中运行。 Instead, they run in a special interrupt context that is not associated with any process.This special context exists solely to let an interrupt handler quickly respond to an interrupt, and then exit. 相反,它们在与任何进程都没有关联的特殊中断上下文中运行。该特殊上下文的存在仅是为了让中断处理程序快速响应中断然后退出。

So, in Linux a processor is doing exactly one of the three things: 1. In user-space, executing user code in a process 2. In kernel-space, in process context, executing on behalf of a specific process. 因此,在Linux中,处理器恰好在执行以下三件事之一:1.在用户空间中,在进程中执行用户代码2.在内核空间中,在进程上下文中,代表特定进程执行。 3. In kernel-space, in interrupt context, not associated with a process, handling an interrupt. 3.在内核空间中,在与进程无关的中断上下文中,处理中断。

I want to understand why this change in design? 我想了解为什么这种设计变化? Wouldn't it be faster if we service interrupts in the context of the running process? 如果我们在正在运行的进程的上下文中服务中断,会不会更快?

It sounds like you are getting confused by terminology. 听起来您对术语感到困惑。 I suspect that what you are calling "a special interrupt context" (certainly Linux documentation uses that term) is really just a shift to an interrupt stack made by the hardware. 我怀疑您所说的“特殊中断上下文”(肯定是Linux文档使用了该术语)实际上只是对硬件产生的中断堆栈的一种转移。 I suspect that Linux has its "interrupt context" simply to disable process-specific activities that should not be done in an interrupt. 我怀疑Linux具有其“中断上下文”只是为了禁用特定于进程的活动,这些活动不应在中断中进行。

I would be shocked if any operating system executed an actual process context switch during an interrupt (thus it is the process that was interrupted that is servicing the interrupt). 如果任何操作系统在中断期间执行了实际的进程上下文切换,我会感到震惊(因此,被中断的进程正在为该中断提供服务)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM