3
我寫了一個簡單的應用程序來啓用rtc中斷。爲什麼在/ proc/interrupts中不啓用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;
}
}
其運行後,我期待在中斷向/proc/interrupts
顯示下IRQ8。
從https://www.kernel.org/doc/Documentation/rtc.txt:
但是它也可以被用來產生從一個慢2HZ到 相對快的8192Hz信號,在2的冪次方的增量。這些信號 由中斷號8報告。(哦!所以那是IRQ 8是 ...)它還可以用作24小時報警,當 報警關閉時提高IRQ 8。
但是沒有變化。該
8: 0 1 IO-APIC-edge rtc0
處於被動。我在這裏錯過了什麼?
好問題!有趣的是,如果你把'char buf [8]; for(int i = 0; i <64; ++ i)read(fd,buf,sizeof(buf))'該程序需要1s的預期。所以它的工作,但中斷仍然不計算。 – derobert 2014-11-03 19:46:53
你讀過[時間(7)](http://man7.org/linux/man-pages/man7/time.7.html)。你不需要RTC來獲得時間! – 2014-11-04 06:33:11
顯示整個'/ proc/interrupts'。 – 2014-11-04 08:32:38