如何创建中断表

发布于 2024-10-19 09:18:22 字数 296 浏览 4 评论 0原文

我的操作系统课程有一个家庭作业,我需要为模拟操作系统编写一个中断表。从之前的作业中,我已经设置了适当的驱动程序:

我的理解是,我应该有一个中断类型数组,按照 interrupt_table[x] 的方式,其中 x = 0 表示陷阱,x = 1 表示时钟中断等。interrupt_table 应包含指向每种中断类型的相应处理程序的指针,其中然后应该打电话给合适的司机吗?我的理解正确吗?谁能指出我创建这些处理程序的正确方向?

感谢您的帮助。

I have a homework assignment for my Operating Systems class where I need to write an interrupt table for a simulated OS. I already have, from a previous assignment, the appropriate drivers all set up:

My understanding is that I should have an array of interrupt types, along the lines of interrupt_table[x], where x = 0 for a trap, x = 1 for a clock interrupt, etc. The interrupt_table should contain pointers to the appropriate handlers for each type of interrupt, which should then call the appropriate driver? Am I understanding this correctly? Could anyone point me in the right direction for creating those handlers?

Thanks for the help.

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

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

发布评论

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

评论(3

丢了幸福的猪 2024-10-26 09:18:22

有关中断处理程序的大多数细节因操作系统而异。唯一接近通用的是,您通常希望在中断处理程序本身中尽可能少地进行合理的操作。通常,您只需确认中断,记录足够的输入信息,以便在准备好时能够处理它,然后返回。其他一切都是单独完成的。

Most details about interrupt handlers vary with the OS. The only thing that's close to universal is that you typically want to do as little as you can reasonably get away with in the interrupt handler itself. Typically, you just acknowledge the interrupt, record enough about the input to be able to deal with it when you're ready, and return. Everything else is done separately.

忘羡 2024-10-26 09:18:22

你的理解听起来不错。

这个模拟操作系统的模拟程度到底如何?如果它完全在你的教授自己设计的“机器”上运行,那么毫无疑问她给出了一些关于提供什么中断、如何探测可能存在的中断以及中断什么类型的任务的规范处理程序应该做的。

如果是成熟的 x86 计算机或类似的计算机,也许是 Linux arch/x86/pci/irq.c 可以为您提供提示。

Your understanding sounds pretty good.

Just how simulated is this simulated OS? If it runs entirely on a 'machine' of your professor's own design, then doubtless she's given some specifications about what interrupts are provided, how to probe for interrupts that may be there, and what sorts of tasks interrupt handlers should do.

If it is for a full-blown x86 computer or something similar, perhaps the Linux arch/x86/pci/irq.c can provide you with tips.

智商已欠费 2024-10-26 09:18:22

收到中断后执行的操作取决于特定的中断。经验法则是找出特定中断需要注意的关键内容,然后“仅”执行该操作(仅此而已)并尽快退出处理程序。此外,中断处理程序只是驱动程序的一小部分(这就是您应该如何设计的)。例如,如果您在某个串行端口上收到传入字节的中断,那么您只需从寄存器中读取该字节并将其放入某个“易失性”变量中,结束处理并退出处理程序。其余的(例如,您将如何处理串行端口上的传入字节)可以在驱动程序代码中处理。

经验法则仍然是:“不多不少”

What you do upon receiving interrupt depends on the particular interrupt. The thumb rule is to find out what is critical that needs to be attended to for the particular interrupt, then do "just" that (nothing more nothing less) and come out of the handler as soon as possible. Also, the interrupt handlers are just a small part of your driver (that is how you should design). For example, if you receive an interrupt for an incoming byte on some serial port, then you just read the byte off the in-register and put it on some "volatile" variable, wind up things and get out of the handler. The rest (like, what you will do with the incoming byte on the serial port) can be handled in the driver code.

The thumb rule remains: "nothing more, nothing less"

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