Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Real time clock (rpcc)
@ 1997-06-25  4:00 Rob Kirkbride
  1997-06-26  4:00 ` Jeffrey Mogul
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Kirkbride @ 1997-06-25  4:00 UTC (permalink / raw)



I am trying to use rpcc to give me accurate times in order that I can
trigger a timer every 50ms. This generates a SIGALRM and then I use the
rpcc instruction to find whether I have am late servicing the timer and
if so by how much.

        As I understand the top 32 bits of the register is decremented
when the program is NOT running on the cpu. The bottom 32 bits are
incremented I thought by a piece of hardware all the time. The problem
is that as the processor becomes loaded the bottom 32 bits slow down.
This would seem to be impossible unless the operating system is
maintaining this counter.

        Does anyone know more about the rpcc instruction? Also my code
is not safe in a multi-processor system which I would like it to be.

        Should I be using an alternative method for generating regular
alarms preferably by something that doesn't slow down if the system
becomes loaded!

Any help would be much appreciated,

Rob
-- 
Rob Kirkbride



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Real time clock (rpcc)
  1997-06-25  4:00 Real time clock (rpcc) Rob Kirkbride
@ 1997-06-26  4:00 ` Jeffrey Mogul
  1997-06-27  4:00   ` Rob Kirkbride
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Mogul @ 1997-06-26  4:00 UTC (permalink / raw)



In article <nK9t0CA9VVszEwhs@RK-COMP.DEMON.CO.UK>, Rob Kirkbride <rk-comp@rk-comp.demon.co.uk> writes:
|> I am trying to use rpcc to give me accurate times in order that I can
|> trigger a timer every 50ms. This generates a SIGALRM and then I use the
|> rpcc instruction to find whether I have am late servicing the timer and
|> if so by how much.
|> 
|> Also my code
|> is not safe in a multi-processor system which I would like it to be.

If you can tolerate a few microseconds of overhead, and if you are
running Digital UNIX V4.0 or later, you can configure the kernel
to provide microsecond resolution from the gettimeofday() system
call.

The kernel does this by using the RPCC instruction to interpolate
between the 1024 Hz clock interrupts.  As you observe, this can
be tricky on a multiprocessor.  However, my understanding is that
the kernel code solves this problem, using a fairly subtle algorithm
to make sure that the interpolation is done correctly.  It might
be very hard (or even impossible) to do this efficiently inside
user-level code.

For more details, see
	http://www.supelec.fr/decus/faq/faq-Digital-UNIX.html#P9

-Jeff



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Real time clock (rpcc)
  1997-06-26  4:00 ` Jeffrey Mogul
@ 1997-06-27  4:00   ` Rob Kirkbride
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Kirkbride @ 1997-06-27  4:00 UTC (permalink / raw)



>If you can tolerate a few microseconds of overhead, and if you are
>running Digital UNIX V4.0 or later, you can configure the kernel
>to provide microsecond resolution from the gettimeofday() system
>call.
>
>The kernel does this by using the RPCC instruction to interpolate
>between the 1024 Hz clock interrupts.  As you observe, this can
>be tricky on a multiprocessor.  However, my understanding is that
>the kernel code solves this problem, using a fairly subtle algorithm
>to make sure that the interpolation is done correctly.  It might
>be very hard (or even impossible) to do this efficiently inside
>user-level code.
>
>For more details, see
>       http://www.supelec.fr/decus/faq/faq-Digital-UNIX.html#P9
>
>-Jeff

Thanks for your help, I have decided to use timers instead. I feel these
should be more accurate than me trying to work out how late I am or
whatever. I suspect there implementation is better than I could manage
as well. I do have a question regarding these however. See my new thread
on signals.

Rob

-- 
Rob Kirkbride
rob@rk-comp.demon.co.uk



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-06-27  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-06-25  4:00 Real time clock (rpcc) Rob Kirkbride
1997-06-26  4:00 ` Jeffrey Mogul
1997-06-27  4:00   ` Rob Kirkbride

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox