Real-Time Java and High Resolution Timers

Any modern x86/x64 processor worth its salt comes equipped with an Advanced Programmable Interrupt Controller, or APIC.  Among the features that an APIC provides is access to high resolution timers.  Without such capability, the default interrupt source for timer and cyclic operations has a precision on the order of 10 milliseconds -- hardly fine-grained enough for any serious real-time work.

The cyclic subsystem, introduced in Solaris 8, gives Solaris the capability to support high resolution timers.  The Sun Java Real-Time System version 2.0, available for Solaris on both x86 and Sparc platforms, includes an additional package called SUNWrtjcJava Real-Time System cyclic driver.  This package exposes an interface to the cyclic subsystem, normally only available to the kernel.  For those already familiar with Sun's Java RTS, you've no doubt noticed that you either need to run as superuser or assign a set of fine-grained privileges to an ordinary user account. (sys_res_config, proc_priocntl, proc_lock_memory and proc_clock_highres).  The proc_clock_highres privilege gives access to those timers.

Originally developed on an AMD Athlon-based PC, I recently moved a Real-Time Java project over to my Toshiba Tecra A1 laptop running the same version of Solaris and Java RTS.  With the goal of getting in a little development time during a long flight, that migration suddenly casued timings to be all wrong.  Why, might you ask, would moving an application from one seemingly identical Solaris environment to another cause this unusual behavior?  Turns out that even though the laptop, a Pentium 4M based system, has an APIC, it was never exposed by the laptop BIOS.  In this scenario, regardless what you do from a Solaris perspective, you'll never get access to the high-res timers. 

This phenomenon appears to be most prevelant in laptops.  As they account for about 50% (or more?) of PCs sold today, developers have a realistic chance of running into this situation.  You can issue this magic Solaris incantation to determine if your system has high-res timer support:

   # echo "psm_timer_reprogram::print"  | mdb -k

If anything but 'apic_timer_reprogram' is then displayed, your machine has no exposed APIC, and is probably unsuitable for Java RTS.  In some cases the BIOS may be configurable with regards to APIC support; in many others it is simply not available.

In the absence of an APIC, there is the potential to improve the high-resolution timing by setting the following tunable in /etc/system:

   set hires_tick=1

Following a reboot, this would change the clock tick frequency from 100 to 1000 ticks per second. This frequency can then be further tuned by setting the hires_hz tunable to the desired value:

   set hires_hz=10000

The default value is 1000 ticks per second; higher values are not officially supported.

Note that tuning your machine in this way does not come without cost.  It is likely to degrade overall performance, as the system will need to spend a larger proportion of time handling the larger frequency of clock interrupts.1

   [1] Thank you  Christophe Lizzi for your explanation of the problem and potential workaround.



I'm trying to install RTS 2.0 on my laptop of x86. There is the following message:

SUNWrtjc only supports Solaris 10 11/06 and cannot be installed on
Solaris 10 8/07 s10x_u4wos_12b X86
Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
Use is subject to license terms.
Assembled 16 August 2007
checkinstall script suspends

Installation of <SUNWrtjc> was suspended (administration).
No changes were made to the system.

I think i'm using Solaris 10 8/07, which I recently downloaded. But I couldn't find where to download Solaris 10 11/06. I would be really appreciated for any suggestions...


Posted by Paul on September 27, 2007 at 08:00 PM EDT #

With the advent of Java RTS 2.0 Update 1, support for Solaris 10 (8/07) is included. So there's no need to search for older versions of Solaris.

Posted by guest on December 14, 2007 at 03:26 PM EST #

I don't understand how setting hires_tick=1 changes the clock tick frequency from 100 to 1000 ticks per second. I assume hires_tick is a simple boolean value, and I have the choice of either 100 (a tick every 10ms) or 1000 (a tick every 1ms). But then what about the hires_hz setting? It appears to be redundant, since hires_tick=1 seems to have a meaning identical to hires_hz=1000. Does hires_hz simply override the hires_tick setting?

Posted by Trevor on January 06, 2009 at 03:02 AM EST #


I just did a little experimenting here. In order to specify a higher clock frequency, you must first set hires_tick=1 regardless what you do with hires_hz. Placing an entry in /etc/system which looks like this:

set hires_tick=1

is identical to:

set hires_tick=1
set hires_hz=1000

To set an even higher clock tick frequency (at your own peril), say 10000, edit /etc/system to look like this:

set hires_tick=1
set hires_hz=10000

Posted by James Connors on January 12, 2009 at 01:09 PM EST #

Can Java RTS be installed on OpenSolaris?

Posted by Ed on January 15, 2009 at 06:57 AM EST #

Re: Can Java RTS be installed on OpenSolaris?

1) First off, is it not supported.

2) The cyclic driver mentioned above is compiled specifically for a Solaris release. In order for it to work on the version of OpenSolaris you're using, it's source would have to be re-compiled on a system running the same version. We hope to decouple this dependency in the future.

3) Unfortunately the cyclic driver source code is not publicly available.

3) Without the cyclic driver, as mentioned above, you won't get high resolution timers. You can increase the clock rate in Solaris as the blog entry suggests to get a finer resolution, and try running JavaRTS. For the overhead ramifications take a look at this follow-on entry:


Posted by James Connors on January 16, 2009 at 02:51 AM EST #

Post a Comment:
  • HTML Syntax: NOT allowed

Jim Connors-Oracle


« July 2016