LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How to share RTC interrupt? (https://www.linuxquestions.org/questions/linux-kernel-70/how-to-share-rtc-interrupt-766733/)

ranji 11-04-2009 03:54 AM

How to share RTC interrupt?
 
In linux, are we able to share the RTC interrupt? I found that in the diver file(/usr/src/linux-2.6.24.7/drivers/char/rtc.c)it is written as "IRQF_DISABLED"only so I changed it to "IRQF_SHARED" and recompiled the kernel. But after that while booting it is showing that "IRQ 8 is not free" and when i try to open the rtc it is showing "bad file descriptor" .Is it the problem with my editing? or compilaton? anybody can help me,please?


thanks in advance.

cladisch 11-04-2009 04:20 AM

On standard PCs, the RTC is an ISA device; its interrupt cannot be shared.

ranji 11-05-2009 12:30 AM

Thanks for your reply.But I heard that ISA bus is obsolete and nowadays it is not used.

cladisch 11-05-2009 10:19 AM

Quote:

Originally Posted by ranji (Post 3745290)
Thanks for your reply.But I heard that ISA bus is obsolete and nowadays it is not used.

Modern computers have no ISA bus, but the old ISA devices are still implemented in the southbridge or as LPC devices.
From the software side, these device behave exactly the same.

ranji 11-06-2009 10:31 PM

Thanks Cladisch. I decided to use hardware interrupts to get precise timing. I have heard that now PIT and RTC is emulated by HPET and we can use the remaining timers of this high precision timer.But using this may make machine dependency . Is there any way to get precise timing in linux(microsecond accuracy)?

cladisch 11-10-2009 04:40 AM

What do you mean with "timing"? Do you want to read the current time, or do you want to schedule to execute some code?

Reading the current time can be done with do_gettimeofday().

If you have to run some timer function, you can use the RTC timer, but this won't work if another driver or application is already using it.
You can use the hrtimer to get precise timing on machines that support it; if not, the hrtimer functions use the HZ system timer.

ranji 11-12-2009 03:26 AM

Yes,i want to run a timer so that i can write some function which will be invoked when the timer ticks.But since we are not able to share the rtc timer how we will invoke the function? can we use the existing driver ("rtc.c")?

Is this hrtimer similar to HPET? and how can i know that my machine will support it?

Thanks in advance.

cladisch 11-12-2009 04:19 AM

Quote:

Yes,i want to run a timer so that i can write some function which will be invoked when the timer ticks.
What do you need the timer for?

Quote:

But since we are not able to share the rtc timer how we will invoke the function?
rtc_register()

Quote:

Is this hrtimer similar to HPET?
Yes; HPET is one of the possible implementations of the hrtimer interface.

Quote:

and how can i know that my machine will support it?
hrtimer is always supported; the accuray may be different.

ranji 11-13-2009 01:06 AM

Quote:

What do you need the timer for?
I need the timer to execute a periodic task.This periodic task will send a burst of UDP datagrams every period.By using the hardware interrupt we will get the interrupt in a precise period(timing).
But using rtc we can get the interrupts in a predefined set of values. ie even if you want 1 ms you cannot get it. you can get only1/1024,1/512ms etc.So is there any way to get that?:scratch:

cladisch 11-13-2009 01:37 AM

Quote:

I need the timer to execute a periodic task.This periodic task will send a burst of UDP datagrams every period.
I doubt you'll be able to send network packets from an interrupt handler; you'll need a workqueue or something like that.

Quote:

But using rtc we can get the interrupts in a predefined set of values. ie even if you want 1 ms you cannot get it. you can get only1/1024,1/512ms etc.So is there any way to get that?
UDP packets are quite asynchronous anyway; the receiver should be able to handle jitter.

ranji 11-17-2009 12:34 AM

If the receiver wants precise period , We cannot assure that period using RTC. Can we use HPET for this?

cladisch 11-18-2009 07:35 AM

Quote:

We cannot assure that period using RTC. Can we use HPET for this?
Yes, if the machine has it.

ranji 11-19-2009 04:53 AM

Thanks cladisch,

I hope my BIOS supports hpet.
$dmesg | grep hpet
hpet clock event registered
hpet0:at MMIO 0xfed00000,IRQs2,8,0,0
hpet0:4 64-bit timers,14318180Hz
hpet-resorces:0xfed00000 is busy .

In some others it is hpet0:at MMIO 0xfed00000,IRQs2,8,0,
hpet0:3 64-bit timers,14318180Hz


This is the result that i found.Out of four timers ,two will be used for 8254 and rtc if we are using the legacy replacement mode and it will be routed to irq 0 and 8 . am i right? How can i know that the BIOS is supporting the access of others? and if yes how i will access? I tried the userspace code that is given in the hpet.txt. but it fails in my pc and it is working in others.

cladisch 11-19-2009 06:31 AM

Quote:

hpet0:at MMIO 0xfed00000,IRQs2,8,0,0
hpet0:at MMIO 0xfed00000,IRQs2,8,0

Out of four timers ,two will be used for 8254 and rtc if we are using the legacy replacement mode and it will be routed to irq 0 and 8 . am i right? How can i know that the BIOS is supporting the access of others?
The other(s) can be used if they have an IRQ different from 0.
In your examples, this is not the case.

However, the first timer is used by the kernel and can be used with all the normal timer functions; if you have a recent enough kernel, timers created by timer_create() or timerfd_create() will be able to give you 1000 Hz.

ranji 11-21-2009 03:23 AM

Quote:

hpet0:at MMIO 0xfed00000,IRQs2,8,0,0
hpet0:at MMIO 0xfed00000,IRQs2,8,0
In the first case it is working and in the second it is not.why it happens so?if we are emulating timer using the hpet timer0 who is making the irq line from 2 to 0(timer irq line)?


All times are GMT -5. The time now is 02:49 AM.