Re: a crash course on time

Paul Gortmaker (Paul.Gortmaker@anu.edu.au)
Fri, 22 Nov 1996 14:17:49 +1100 (EST)

- From: a sun <asun@zoology.washington.edu>
- Date: Thu, 21 Nov 1996 12:52:41 -0800 (PST)
- To: axp-list@redhat.com, gpg109@rsphy1.anu.edu.au
>
> i'm able to bring my udb/alpha to a grinding halt with the following
> few lines:
>
> int fd;
> struct tm time;
>
> fd = open("/dev/rtc", O_RDONLY);
> ioctl(fd, RTC_RD_TIME, &time);
> close(fd);
>
> needless to say, this is not good. from the behavior of the code, it
> feels like interrupts never get re-enabled after the ioctl. if the rtc

Actually it is timer interrupts that never happen again, and not a
missing sti() -- MvS dug into this a bit on an old(er?) Jensen board
and found that this is what happens. It is not the ioctl() but rather
the disabling of periodic interrupts from the RTC that is implicit
upon a close. You can try changing close(fd); to kill(getpid(), SIGSTOP);
to check this.

On the i386, you have timer interrupt events from the 8253 Programmable
Interrupt Timer @ 0x40/IRQ=1 and that is entirely independent of the
mc146818 RTC @ 0x70/IRQ=8. But on the Alpha, the 8253 is not used for
timer interrupts, but rather the RTC is (according to arch/alpha/irq.c).
Don't ask me why the 8253 isn't used -- I don't know enough about what
capabilities the various Alpha boxes have or don't have to comment.

So the RTC driver thinks it is free to meddle with the interrupt generation
and IRQ rate, as it has no idea the kernel is using it. You close the
device and your timer interrupt goes bye-bye.

The fix? To arch/alpha/irq.c do a:

- #define IS_RESERVED_IRQ(irq) ((irq)==2) /* IRQ 2 used by hw cascade */
+ /* IRQ 2 used by hw cascade, IRQ 8 is RTC, used by kernel for timer */
+ #define IS_RESERVED_IRQ(irq) ((irq)==2 || (irq)==8)

That will stop the RTC driver from a successful init, and hence stop you
from shooting yourself in the foot by trying to use it for 2 things at once.

Paul.

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com



Feedback | Store | News | Support | Product Errata | About Us | Linux Info | Search | JumpWords
No Frames | Show Frames

Copyright © 1995-1997 Red Hat Software. Legal notices