linux内核hz能大于1000,linux內核的最大中斷頻率是Hz,kHz,MHz還是GHz?

Before I start: yes, I'm aware that the answer is architecture dependent - I'm just interested in a ballpark figure, in terms of orders of magnitude.

在我開始之前:是的,我知道答案取決於架構 - 我只是對數量級的球場數據感興趣。

Is there an upper limit imposed by the linux kernel on interrupt frequency?

linux內核對中斷頻率有上限嗎?

Background: I want to interface with a camera module from within Linux. The module has a clocked parallel data output (8 bits, at ~650kHz), which I want to read data from and store in a buffer for access through, eg, /dev/camera.

背景:我想在Linux中與相機模塊連接。該模塊具有時鍾並行數據輸出(8位,~650kHz),我想從緩沖區讀取數據並存儲在緩沖區中,以便通過例如/ dev / camera進行訪問。

I have a basic driver written, and it is monitoring the appropriate interrupt line. If I leave a wire hanging off the interrupt pin, I get interrupts from white noise. However, if I hook up a higher frequency signal (atm ~250kHz from a 555 timer) then no interrupts are triggered. (I've confirmed this with /proc/interrupts)

我有一個基本的驅動程序,它正在監視適當的中斷線。如果我將電線懸掛在中斷引腳上,我會受到白噪聲的干擾。但是,如果我連接一個較高頻率的信號(555定時器的atm~250kHz),則不會觸發中斷。 (我用/ proc / interrupts確認了這一點)

My thinking is that this can either be from the GPIO module on the processor not being able to deal with such high frequencies (which would be silly - that's not particularly high), or it could be a kernel issue. What do people think?

我的想法是,這可能來自處理器上的GPIO模塊無法處理如此高的頻率(這將是愚蠢的 - 這不是特別高),或者它可能是內核問題。人們怎么想?

1 个解决方案

#1

3

Look at it this way. Modern CPUs execute around 109 instructions per second.

以這種方式看待它。現代CPU每秒執行大約109條指令。

In order to handle an interrupt you need to execute some 100-1000 instructions (save the context, do I/O, signal end of interrupt handling, restore the context). That gives you some 106 - 107 interrupts per second max.

為了處理中斷,您需要執行大約100-1000條指令(保存上下文,執行I / O,中斷處理的信號結束,恢復上下文)。這給你每秒最多106-107次中斷。

If you spend all the time in handling interrupts, then nothing is left for the rest of the system and programs.

如果您花費所有時間處理中斷,那么系統和程序的其余部分就不會留下任何東西。

So, think of some 105 interrupts/second (100 KHz) being the maximum practical interrupt rate.

因此,可以將105個中斷/秒(100 KHz)視為最大實際中斷率。

There may be other limitations imposed by the circuitry and I'm not too familiar with this aspect. But it's unlikely for the kernel to somehow explicitly limit the interrupt rate. I see no good reason for it and I don't think it's something that can be easily done either.

電路可能存在其他限制,我對這方面不太熟悉。但內核不太可能以某種方式明確限制中斷速率。我認為沒有充分的理由,我認為這也不容易做到。

Now, there are things like DMA that let you have interrupts not on every byte of input/output data, but on a buffer of several kilobytes or even megabytes. E.g. you prepare your data for output in a memory buffer and tell to the DMA controller that it can now send it out from the buffer. When done, it will trigger an interrupt signalling the completion of the transfer and you'll be able to initiate another one. It works the same in the other direction of transfers. You get an interrupt when the entire buffer is filled with input data.

現在,像DMA這樣的東西讓你不是在輸入/輸出數據的每個字節上都有中斷,而是在幾千字節甚至兆字節的緩沖區上。例如。您准備數據以便在內存緩沖區中輸出,並告訴DMA控制器它現在可以從緩沖區發送出去。完成后,它將觸發一個中斷,表示傳輸完成,您將能夠啟動另一個。它在轉移的另一個方向上的工作方式相同。當整個緩沖區充滿輸入數據時,您會收到中斷。

I think you may be facing a hardware limitation if you can receive interrupts at lower rates only.

如果您只能以較低的費率接收中斷,我認為您可能面臨硬件限制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值