硬件计时器中断在哪里? [英] where is hardware timer interrupt?

查看:82
本文介绍了硬件计时器中断在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是异常和中断"表(我将其理解为IDT) 摘自《英特尔架构软件开发人员手册》

this is Exceptions and Interrupts table(which I understand as IDT) from the "Intel Architecture Software Developer Manual"

计时器中断在哪里使上下文切换成为可能? (用于多任务)

where is Timer interrupt which makes context switching possible?? (for multi-tasking)

如果这是一个愚蠢的问题,请修正我的理解. 预先谢谢你

if this is a stupid question, please fix my understanding. thank you in advance

推荐答案

是的,是的,如果我们谈论的是传统的8254 PIT计时器,它位于IRQ0,即矢量32.现代机器上Linux操作系统中的计时器. [请注意,向量分配32实际上是相当任意的.在对8259(PIC)或APIC进行编程时会设置该位-但这不是一个坏选择,因为32是保留位之后的第一个向量.肯定比混合硬件中断和异常向量更好,就像DOS那样-因此,由于映射了INT0,所以没有办法从INTR 5(也就是向量13)中分辨出一般保护错误(上表中的向量13).到向量8,并且5 + 8 = 13).从内存来看,INTR5的使用不是特别好-类似于LPT2 :(第二个并行端口).但是,不重叠它们仍然是一个好主意……Henc是向量20到31的保留".

Well, yes, if we are talking about the traditional 8254 PIT timer, it is at IRQ0, which is vector 32. But that is not generally used as the timer in the Linux operating system on modern machines. [Note that the vector assignment of 32 is really quite arbitrary. It is set when programming the 8259 (PIC) or APIC - but it's not a bad choice, since 32 is the first vector AFTER the reserved ones. It's certainly better than mixing the hardware interrupts with exception vectors, as DOS would do - so there was no way to tell a General Protection fault (vector 13 in the table above) from a INTR 5 (also vector 13, as the INT0 was mapped to Vector 8, and 5 + 8 = 13). From memory, INTR5 wasn't particularly well used - something like LPT2: (Second parallel port). But it's still a good idea to not overlap them... Henc the "reserved" for the vectors 20 to 31.

实际上控制系统时序的IRQ很可能是本地APIC计时器,并且它的向量在硬件中的固定方式与原始PC相同.

The IRQ that actually controls the timing of the system is most likely a Local APIC timer, and it's vector is not fixed in hardware in the same way as the original PC.

此外,随着消息信号中断"的出现,完全有可能(超过)256个中断向量.

Also, with the advent of "message signalled interrupts", it is entirely possible to have (much) more than 256 interrupt vectors.

我不同意向量0-19是不可屏蔽的中断"的说法.除了NMI(向量2),它们都是异常(又称TRAPS或FAULTS)-也就是说,系统中某些错误情况所驱动的事件-向量零是整数除以零的结果,向量1是"单步"指令中断[和其他一些调试"陷阱,例如写入与启用的调试寄存器匹配的任何地址"],向量3是"int3"指令(操作码0xcc)的结果,向量4是执行"INTO"的结果(溢出时为'o',而不是零时为0).当访问未在页表中标记为存在的内存时,使用向量14.它们确实是不可屏蔽的",但除少数例外,它们是当时指令执行的直接后果-因此它们与程序本身同步.

I don't agree with the wording "vector 0-19 are non-maskable interrupts". Aside from NMI (vector 2), they are all EXCEPTIONS (aka TRAPS or FAULTS) - that is, an event driven by some error condition in the system - vector zero is the result of an integer divide by zero, vector 1 is a "single step" instruction interrupt [and a few other "debug" traps, such as "write to any address matching an enabled debug register"], vector 3 is the result of a "int3" instruction (opcode 0xcc), vector 4 is the result of executing "INTO"(that's 'o' as in overflow, not 0 as in zero). When accessing a piece of memory not marked as present in the page-tables, vector 14 is used. They are indeed "non-maskable", but they are, with a few exceptions, direct consequences of the instructon executing at the time - so they are synchronous to the program itself.

异常是双重故障"异常和机器检查故障".

The exceptions are the "Double fault" exception and "machine check fault".

双重错误是指处理器在处理另一个异常期间检测到错误-通常是因为操作系统已执行了一些愚蠢的操作,例如将堆栈设置为无效,从而导致页面错误,从而尝试使用堆栈存储页面错误返回地址,但由于无法访问堆栈而失败.因此,双重故障处理程序通常被设置为任务切换中断",并加载新的堆栈以确保双重故障可以继续.如果双重故障处理程序无法正确运行,则处理器将三重故障".这通常意味着在PC平台上重新启动".双重故障通常是无法恢复的-处理程序将(尝试)提供有关发生的情况以及如何进入此状态的一些信息,但是一旦完成,系统将重新启动或等待有人进入并按下复位按钮.

Double fault is when the processor detects a fault during the handling of another exception - typically because the operating system has done something daft, like set the stack to somewhere invalid, and thus gets a page-fault, tries to use the stack to store the page-fault return address and that fails because the stack is not accessible. Double fault handlers, thus, tends to be set as "task switch interrupts", and load a new stack to make sure the double fault can continue. If the double fault handler can't run correctly, the processor will "triple-fault". This usually means "reboot" on PC platforms. Double faults are normally not recoveriable - the handler will (try to) provide some information about what happened, and how it got into this state, but once that's done, the system either reboots or waits for someone to come and push the reset button.

机器检查故障是处理器检测到不可恢复的错误-例如不可恢复的内存错误或高速缓存奇偶校验错误等.这些通常也是不可恢复的,但并非与正在执行的指令直接耦合,而是更多地涉及到.不同事件的组合(对内存内容已变坏的地址进行内存读取或类似操作).

Machine check fault is where the processor detects an unrecoverable error - such as irrecoverable memory error or a cache parity error, etc. These are typically also non-recoverable, but not DIRECTLY coupled with the instruction being executed, but more on a combination of different events (memory read of an address where the memory content has gone bad, or similar).

这篇关于硬件计时器中断在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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