Re: Timer, sigprocmask, etc. as memory mapped regions for performance

Alexander Kjeldaas (astor@guardian.no)
Tue, 3 Feb 1998 17:02:38 +0100 (MET)


On Mon, 2 Feb 1998, Stephen D. Williams wrote:

> I've been meaning to bring this up:
>
> There are a number of frequently needed and used services that could
> be provided for (optionally) as memory mapped regions in a process.
>
> I write very high-speed high-transaction servers. In profiling
> servers, especially asynchronous servers that use signals (SIGIO,
> which async Sybase uses and is actually pretty slick since you can
> have better latency than a select() loop process if you have other
> work to be done), it becomes obvious that certain often used and
> generally no-work system calls should be optimized.
>
> gettimeofday, sigprocmask, and others fall into this category.
>
> gettimeofday for instance could be a page mapped into every process
> that just shares a kernel page with the current timer value.
> Completely free instant timers. Maybe mmaping /proc/rtc is a clean
> way to do this.

A variation on your proposal which gives greater accuracy is to use the
different "time base" registers found on most modern CPUs in connection
with some constants obtainable from kernel-space. A "time base" register
is required in all Alpha, PowerPC and SPARCv9 designs. It's also avaiable
on pentiums and later ix86 chips. To compute the time of day you'll need:

* Time of day at beginning of current epoch
* Time base value at beginning of current epoch
* Time base update frequency
* The contents of the time base register

In most cases, the first three inputs are constants, but they must often
be calculated on boot-time and cannot be hard-coded in the application.
Also on some architectures [PowerPC for instance], the frequency used to
update the "time base" register is allowed to change as long as the OS is
notified of the change, so having them mapped from kernel-space could be a
good idea.

astor

--
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/