LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-04-2009, 03:54 AM   #1
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Rep: Reputation: 0
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.
 
Old 11-04-2009, 04:20 AM   #2
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
On standard PCs, the RTC is an ISA device; its interrupt cannot be shared.
 
Old 11-05-2009, 12:30 AM   #3
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for your reply.But I heard that ISA bus is obsolete and nowadays it is not used.
 
Old 11-05-2009, 10:19 AM   #4
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
Quote:
Originally Posted by ranji View Post
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.
 
Old 11-06-2009, 10:31 PM   #5
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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)?
 
Old 11-10-2009, 04:40 AM   #6
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
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.
 
Old 11-12-2009, 03:26 AM   #7
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 11-12-2009, 04:19 AM   #8
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
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.
 
Old 11-13-2009, 01:06 AM   #9
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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?
 
Old 11-13-2009, 01:37 AM   #10
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
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.
 
Old 11-17-2009, 12:34 AM   #11
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
If the receiver wants precise period , We cannot assure that period using RTC. Can we use HPET for this?

Last edited by ranji; 11-17-2009 at 12:35 AM.
 
Old 11-18-2009, 07:35 AM   #12
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
Quote:
We cannot assure that period using RTC. Can we use HPET for this?
Yes, if the machine has it.
 
Old 11-19-2009, 04:53 AM   #13
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 11-19-2009, 06:31 AM   #14
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 228

Rep: Reputation: 54
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.
 
Old 11-21-2009, 03:23 AM   #15
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 12

Original Poster
Rep: Reputation: 0
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)?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
control is not going to interrupt handler when interrupt remyasj LinuxQuestions.org Member Intro 1 11-12-2009 12:56 AM
RTC Alarm wakes up, even while BIOS has RTC alarm disabled mastermind2501 Linux - Newbie 2 12-22-2008 03:32 PM
control is not going to interrupt handler when interrupt comes in serial driver sateeshalla Linux - Kernel 1 05-04-2006 09:43 AM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 09:47 AM
Share interrupts with /dev/rtc (IRQ 8) godOfThunder Linux - Software 1 08-03-2004 12:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration