系统调用是否完全在软件中断处理程序中执行? [英] do system calls execute inside a software interrupt handler in entirety?

查看:243
本文介绍了系统调用是否完全在软件中断处理程序中执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统调用是否完全在软件中断处理程序的上下文中执行?

Do system calls execute in the context of a software interrupt handler in entirety?

我的意思是,违反ISR执行时间非常短的策略,某些系统调用(如read())可能需要很长时间才能返回.系统调用是否已分流到其他线程?怎么运作的?

I mean, some system calls like read() could take a long time to return, against the policy that ISR should be very short in execution time. Are system calls offloaded to other threads? How does that work?

[对任何内核的引用都可以]

[A reference to any kernel is fine]

推荐答案

系统调用 ISR 中的大多数内核上运行.快速浏览一下以前的Linux版本,您会发现int $Ox80会调用内核.从内核开发的角度来看,此解决方案可能是最简单的解决方案,但它有一个很大的缺点:只要运行ISR,就可以运行ISR.中断被禁用.禁用中断时间太长,因为很明显您的系统将不会响应(它会延迟外部事件,不会按时重新安排时间,...).

The syscalls run on most kernels inside an ISR. Take a quick glance at a former release of Linux and you will notice the int $Ox80 to invoke the kernel. This solution which is probably the simplest from a kernel development point of view, has a strong drawback: as long as running the ISR; interrupts are disabled. Disabling interrupts too long sucks because it's obvious your system won't be reactive (it delays external events, it doesn't reschedule on time, ...).

抢占是一个明智的解决方案.但是,每当内核由于资源不可用而选择抢占线程时,它通常已经花费大量时间禁用了中断.

Preemption, as Adel explained in his answer is a smart solution. But whenever the kernel choose to preempt a thread because of an unavailable ressource, it has generally already spent a lot of time with interrupts disabled.

系统调用是否已分流到其他线程?

Are system calls offloaded to other threads?

您是对的. 中断线程 和/或线程内核是一个更智能的解决方案.像Solaris和Mac OS X这样的内核更喜欢具有非常简单的ISR,这些ISR只能唤醒高优先级的中断线程.因此,ISR减少到最小处理量,并且大大减少了在禁用中断的情况下运行系统的时间.由于这些中断线程具有较高的优先级,因此它们很可能在ISR返回时运行.很好的是,将再次启用中断,因此不会延迟更高优先级的工作.使用线程内核,例如最新版本的Linux,可以在内核内部完成多项工作,尽管有一个块,但其他进程仍然可以进入内核.

You're right. Interrupt-threads and/or threaded kernel is an even smarter solution. Kernels like Solaris and Mac OS X prefers to have very simple ISRs which just wakeup high priority interrupt threads. Therefore the ISRs are reduced to the minimum processings, and the time the system runs with interrupts disabled is strongly decreased. Because these interrupt-threads have an high priority, they are likely to run at the return of the ISR. What is nice is interrupts will be enabled again, and therefore an even higher priority work wouldn't be delayed. With a threaded kernel, such as Linux in its recent releases, multiple things can be done inside the kernel, and despite one blocks, other process are still able to enter the kernel.

希望获得帮助!

这篇关于系统调用是否完全在软件中断处理程序中执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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