ChorusOS 4.0 Hot Restart Programmer's Guide

2.2 Running the Hot Restart Demonstration Program

Sun Embedded Workshop includes a graphical demonstration of the hot restart feature. The demonstration is based on the well-known program Xmaze, which has been slightly modified to make it hot restartable. Some of the program's data is stored in persistent memory, which means that when the program is restarted, it starts at a point close to the point it had reached prior to the restart. The resulting application is a ChorusOS actor called xdemo_s.

To run the hot restart demonstration program, do the following:

  1. Ensure that your system features are correctly set for hot restart: see "2.1.1 Features".

  2. Adjust the following system tunable parameters to suit the memory requirements of the Xmaze demonstration program, using ews or the configurator(1CC) command line utility:

    Tunable parameter 

    Description 

    Required value 

    pmm.rambankSize Size of persistent memory bank, in bytes 0x400000
    kern.exec.dflSysStackSize Default system stack size, in bytes 0x8000

  3. Configure your system image build to include the X11 library and ChorusOS examples directory, if this is not already the case.

  4. If you have made changes to the system image since the previous build, rebuild the system, copy the system image to the appropriate location (for example, the boot directory if you are using tftp-based boot) , and reboot the target machine.

  5. Ensure that a copy of the xdemo_s actor is present in a directory which is mounted on the target machine. If you use the make root command, a copy of the actor is already stored in build_dir/root/bin/examples. If this directory is not mounted, or you prefer to use a different mounted directory:


    $ cp build_dir/BUILD_EXAMPLES/restartDemo/xdemo_s example_directory
    
  6. Set the target machine's DISPLAY environment variable to the host machine which you are currently working on:


    $ rsh target setenv DISPLAY host_IP_address:0.0
    
  7. Run the restartable actor:


    $ rsh target arun -g 0 example_directory/xdemo_s
    

    The actor will be run as a member of the restart group with group ID 0.

The Xmaze demonstration appears on the screen. As the demonstration runs, it periodically stores its state as data in persistent memory. Let the demonstration advance a little, then restart the actor by typing the following on the host console:


$ rsh akill aid

aid is the actor identifier which is printed on the host console when the actor starts. The actor is restarted, and the Xmaze demonstration continues from a point close to the point it had reached before the restart.

The akill command provoked the restart because it was not passed with the restart-specific option -g. To kill the Xmaze demonstration actor without restarting it, type:


$ rsh target akill -g 0

As the xdemo_s actor is run from the command line, it is a direct actor, and will be started automatically by the system when the site is restarted. To check this, rerun the actor, and then provoke a site restart by typing the following:


$ rsh target restart

When the system has been re-initialized, the demonstration will be restarted.

Of course, this is a very simple illustration of the use of hot restart. The site restart is provoked manually from the command line. As an alternative, try restarting the actor (using akill -g) sufficiently frequently to trigger an automatic site restart. To do this, you will first need to set the system's restart policy to be more sensitive to actor failure. The following configuration will cause a site restart if the actor is restarted twice in the space of four seconds:

Tunable parameter 

Value 

hrCtrl.interval

hrCtrl.maxBadness