LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Thread Tools
Old 11-04-2009, 04:54 AM   #1
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0
How to share RTC interrupt?


[Log in to get rid of this advertisement]
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.
windows_xp_2003 ranji is offline     Reply With Quote
Old 11-04-2009, 05:20 AM   #2
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
On standard PCs, the RTC is an ISA device; its interrupt cannot be shared.
linuxslackware cladisch is offline     Reply With Quote
Old 11-05-2009, 01:30 AM   #3
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
Thanks for your reply.But I heard that ISA bus is obsolete and nowadays it is not used.
linux ranji is offline     Reply With Quote
Old 11-05-2009, 11:19 AM   #4
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
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.
linuxslackware cladisch is offline     Reply With Quote
Old 11-06-2009, 11:31 PM   #5
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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)?
linuxfedora ranji is offline     Reply With Quote
Old 11-10-2009, 05:40 AM   #6
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
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.
windows_vista cladisch is offline     Reply With Quote
Thanked by:
Old 11-12-2009, 04:26 AM   #7
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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.
windows_xp_2003 ranji is offline     Reply With Quote
Old 11-12-2009, 05:19 AM   #8
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
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.
linuxslackware cladisch is offline     Reply With Quote
Old 11-13-2009, 02:06 AM   #9
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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?
linux ranji is offline     Reply With Quote
Old 11-13-2009, 02:37 AM   #10
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
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.
linuxslackware cladisch is offline     Reply With Quote
Old 11-17-2009, 01:34 AM   #11
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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 01:35 AM..
windows_vista ranji is offline     Reply With Quote
Old 11-18-2009, 08:35 AM   #12
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
Quote:
We cannot assure that period using RTC. Can we use HPET for this?
Yes, if the machine has it.
linuxslackware cladisch is offline     Reply With Quote
Old 11-19-2009, 05:53 AM   #13
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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.
windows_xp_2003 ranji is offline     Reply With Quote
Old 11-19-2009, 07:31 AM   #14
cladisch
Member
 
Registered: Oct 2008
Location: Earth
Distribution: Slackware
Posts: 133
Thanked: 23
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.
linuxslackware cladisch is offline     Reply With Quote
Old 11-21-2009, 04:23 AM   #15
ranji
LQ Newbie
 
Registered: Oct 2009
Posts: 8
Thanked: 0

Original Poster
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)?
linuxfedora ranji is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 01:56 AM
RTC Alarm wakes up, even while BIOS has RTC alarm disabled mastermind2501 Linux - Newbie 2 12-22-2008 04:32 PM
control is not going to interrupt handler when interrupt comes in serial driver sateeshalla Linux - Kernel 1 05-04-2006 10:43 AM
<0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing mrb Linux - Newbie 2 01-09-2005 10:47 AM
Share interrupts with /dev/rtc (IRQ 8) godOfThunder Linux - Software 1 08-03-2004 01:36 AM


All times are GMT -5. The time now is 09:35 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration