13/02/2011

Safety-Critical Java Specification : First Draft Released

The moment we all have been waiting for is here.

The first public version of the Safety-Critical Java Specification (JSR-302) was released. The draft can be downloaded from JSR-302 webpage, go to the Download Section.

To make a good picture of what SCJ is about, read the first two chapters. And if you want to know what we have been contributing to, read the Chapter 9 : Java Metadata Annotations.

08/11/2010

Real-Time Java HelloWorld

Are you starting with Real-time Java and don't know where to look first? Here is a step-by-step tutorial showing you how to install and run simple RT Java programs.

1. Install Real-time Java VM
There is a bunch of RT VMs that you can donwload and use but perhaps the one that is the easiest to install and to play with is Oracle's Java RTS. The current version is Java RTS 2.2. After filling the download form, you should be able to download it to your desktop. The name of the donwloaded file will be something like :  java_rts-2_2-fcs-bin-b19-linux-i586-eval_academic.zip

1.0 Requirements
  • RT Linux - if you want to really run with real-time priorities. However, for starting and learning how to work with RT VMs, a regular linux should do - try eg. Ubuntu or Fedora OS.
1.1  Install the RTJ VM
untar downloaded distributable into /opt/jrts2.2 directory. Let's call it RTJAVA_HOME.
$ export RTJAVA_HOME=/opt/jrts2.2/

For more details, see SUN Java RTS Technical Documentation. Java RTS is distributed under restricted academic license that expires after 365 days but don't worry, you can just dowload a new distribution and re-install it.

1.2. Verify the Installation
Type:
$ $RTJAVA_HOME/bin/java -version
You should see:
java version "1.5.0_20"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_20_Java-RTS-2.2_fcs-b19_RTSJ-1.0.2)
Java Real-Time System HotSpot(TM) 64-Bit Client VM (build 1.5.0_20-b19, mixed mode)

In case you are not running in a real-time environment or your linux does not have the rt-kernel extensions, you will also see the following warning:
Java Real-Time System HotSpot(TM) 64-Bit Client VM warning: Unable to lock pages into memory: insufficient privileges
Java Real-Time System HotSpot(TM) 64-Bit Client VM warning: Cannot use the real-time scheduling class.
You can safely ignore this one for testing RTSJ.

1.3. A missing libcap.so problem
However, a problem can occur when running the "./bin/java" on some systems:
$RTJAVA_HOME/bin/java -version
dl failure on line 824Error: failed /opt/sunrts-2.2/jre/lib/i386/server/libjvm.so,
because libcap.so.1: cannot open shared object file: No such file or directory
This happened to me both on Ubuntu and Fedora OS. There is a detailed description of this problem here (as it appears, I was the first person to identify this issue).

Solution to the missing libcap.so.1 lib is to locate a libcap.so.2 and rename it as libcap.so.1
$ locate libcap.so.2
$ sudo cp /lib/libcap.so.2 /lib/libcap.so.1 


2. Runnig a Real-time HelloWorld program
Now we can finally run some real-time Java code. A classical real-time Java hello world example is below:
import javax.realtime.RealtimeThread;

public class HelloRealtimeWorld extends RealtimeThread {

    String message;

    public void run(){
      message = "Hello Realtime World";
    }
   
    public static void main(String args[]){
      HelloRealtimeWorld thread = new HelloRealtimeWorld();
      thread.start();
      try{
        thread.join();
      } catch(InterruptedException ie){
        System.err.println("got interrupted");
        return;
      }
      System.out.println(thread.message);
    }
}

To compile the Real-Time HelloWorld class:
$ $RTJAVA_HOME/bin/javac -classpath $RTJAVA_HOME/jre/lib/rt2.jar 
-d build/  HelloRealtimeWorld.java 

And, to run:
$ $RTJAVA_HOME/bin/java -cp build/ HelloRealtimeWorld
Hello Realtime World! 

And we are done!

Further resources on RT Java:
Further blog-post on the same topic:
  • http://viswanathj.wordpress.com/2011/04/09/installing-java-rts-on-ubuntu-2/

03/11/2010

October Reading List

The list of papers, books, and other articles that caught my attention during the last month.

Papers:
Books:
Others:

22/10/2010

oSCJ News

Recently, there has been a lot of activity around the oSCJ project, here is a short summary.

We currently develop several new features in parallel:
  • SCJ benchmarks - we have added a set of new SCJ programs to compare performance and memory usage of the SCJ memory management againts real-time garbage collection algorithms
  • SCJ Annotations - soon, our annotation checker will be extended to cover a full-scale of different allocation scenarios to guarantee memory safety of the applications running on oSCJ. Furthermore, this feature will allow us to disable the runtime scope checks in the underlying VM, achieving 5-10% speed-up!
  • SCJ library extensions - as JSR-302 is nearing to its completion, we extend the set of supported features.
Also, the installation and running of oSCJ is now super-easy! First, you can get an academic version of FijiVM - our major platform for running oSCJ. Just contact us so we can send you the Fiji VM distribution!

Installation procedure:
$ wget fivm.tar.gz
$ untar fivm.tar.gz 
cd fivm 
$ hg clone https://scj-jsr302.googlecode.com/hg/ scj

and then compile FijiVM, which will also compile the oSCJ as well:
$ autoreconf -i 
$ ./configure
$ make 

To update oSCJ:
$ cd fivm/scj
$ hg pull
$ hg update 

For your better orientation in the distribution directory, here is a structure of the distribution directory
fivm/                 fivm/scj
  ...
  lib/                this is where "scj.jar" is 
  scj/
    oSCJ/             oSCJ root dir
      doc/              Documenation 
      examples/         oSCJ examples and benchmarks dir
        minicdx/          our CDx benchmark implemented in SCJ
        hello/            SCJ helloworld example
        ...
      scj/              oSCJ library implementation
        ri/               SCJ library source codes
        ...
      tools/            our SCJ tools
        checker/          Static Checker for SCJ
        tck/              TCK for SCJ
  scjruntime/
 


See our oSCJ Code base for the most recent updates.

18/10/2010

Azul@Purdue Project

Recently, our team acquired a revolutionary Azul appliance platform. I had a great opportunity to play with this exciting hardware a little when installing and running the first helloworld programs both in Java and C. This was the first time ever that this machine was used in an academic institution. Here is some more info:

Azul appliance is built around the Vega 3 chip and is a unique virtualization platform that features 54 cores pre processor giving users the power to run up to 800 Java threads in parallel.  Futhermore, the appliance offers ~700GB of memory while running a concurrent GC that achieves garbage collection without any pauses in the host application.


Find more at our webpage: http://sss.cs.purdue.edu/projects/azul/

26/09/2010

Garbage Collection and Real-time Garbage Collection Introduction

Here are some documents and slides you may find useful when studying Garbage Collection and Real-time Garbage Collection:

First, look at SUN's
Memory Management in the Java HotSpotTM Virtual Machine. Its from 2006 but contains a very nice introduction to GC, even parallel and small-pause collection algorithms are mentioned.

An another introduction slides are:
GC Introduction Presentation

When looking at performance of GCs, look at a nice study
Myths & Realities The Performance Impact of Garbage Collection from Steve Blackburn, Perry Cheng and Kathryn McKinley.

For interesting implementation details, I recommend:

16/09/2010

Static Checker for SCJ: Paper and its Presentation

Presentation of our Static SCJ Checker is now available online:


The paper itself can be downloaded from JTRES2010 webpage.