gpt4 book ai didi

kernel - 什么是中断线程?

转载 作者:行者123 更新时间:2023-12-04 20:22:50 24 4
gpt4 key购买 nike

(注意:这不是关于中断 Java/.NET 线程,而是关于内核模式中断。)

你好,

维基百科在 Interrupt handler 中有关于中断线程的说法。文章:

Interrupt threads

Several operating systems - Solaris, NetBSD, Mac OS X, WinCE and FreeBSD, for example - use different scheme known as interrupt threads. An interrupt handler provided by the device driver is just a high-priority thread which runs with interrupts enabled and, more importantly, may block on mutex. This greatly simplifies locking in the kernel. Also, interrupt thread may be preempted by higher-priority interrupt thread.



FreeBSD(以及其他人)显然使用的这种中断线程技术是什么?我在哪里可以阅读更多相关信息?

提前致谢。 :)

最佳答案

硬件通过中断通知操作系统某些事件。当发生错误或当某些外围设备有新数据可用时(用户按下一个键,一个数据包到达网络,一个计时器到期,......),它们会被引发。系统需要快速处理这些中断(以便它看起来响应迅速)。

它们由内核处理。通常,当一个这样的中断到来时,当前运行的代码被停止,并调用内核的一个函数。必须快速响应中断以拥有响应系统,因此它们不能阻止内核等待某些资源,或做类似的事情。经典的解决方案是有一个哑中断函数,只记录中断的次数并返回,然后在内核的主循环中,检查是否有中断发生并调用真正的处理程序。

由于这些中断可以被屏蔽(不可屏蔽中断除外 - NMI),内核可以在内核模式下产生一些线程,并且只让它们取消屏蔽并处理它们。由于这些线程独立于主内核线程,因此它们可以阻塞,前提是有足够的线程来处理线程被阻塞时可能到达的中断。

关于kernel - 什么是中断线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4552807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com