【问题标题】:Why doesn't enabling the rtc interrupt show in the /proc/interrupts?为什么在 /proc/interrupts 中没有启用 rtc 中断显示?
【发布时间】:2014-11-03 18:58:21
【问题描述】:

我编写了一个简单的应用程序来启用 rtc 中断。

#include <stdio.h>
#include <fcntl.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>   

int main() {
    int fd = open("/dev/rtc0",O_RDONLY);
    int hz = 64;

    if (ioctl(fd, RTC_IRQP_SET, hz) == -1){
        printf("ioctl(RTC_IRQP_SET) failed");
        return 1;
    }    
    if (ioctl(fd, RTC_PIE_ON) == -1){
        printf("ioctl(RTC_PIE_ON) failed");
        return 1;
    }    
}

运行后,我预计中断会显示在 IRQ8 下的 /proc/interrupts 中。

来自https://www.kernel.org/doc/Documentation/rtc.txt

不过,它也可用于生成从 2Hz 到 2Hz 的慢速信号 相对较快的 8192Hz,以 2 的幂为增量。这些信号 由中断号 8 报告。(哦!所以就是 IRQ 8 for...) 它也可以用作 24 小时警报,当 闹钟响了。

但没有任何变化。

8: 0 1 IO-APIC-edge rtc0

保持被动。我在这里错过了什么?

【问题讨论】:

  • 好问题!有趣的是,如果您输入char buf[8]; for (int i = 0; i &lt; 64; ++i) read(fd, buf, sizeof(buf)),程序会按预期花费 1 秒。所以它正在工作,但仍然不计算中断。
  • 你读过time(7)。您不需要 RTC 来获得时间!
  • 显示整个/proc/interrupts

标签: linux timer linux-kernel real-time


【解决方案1】:

答案是周期性中断 (PIE) 是使用定时器或 hrtimer(取决于您的机器)而不是 RTC 实现的。你可以看看:

http://lxr.free-electrons.com/source/drivers/rtc/interface.c#L574http://lxr.free-electrons.com/source/drivers/char/rtc.c#L445

基本上,你只有在设置闹钟时才会被打断。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-16
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    相关资源
    最近更新 更多