This discussion is archived
6 Replies Latest reply: Jul 20, 2008 2:44 PM by 807557 RSS

Running Java-RTS on vanilla kernel, no root privileges

807557 Newbie
Currently Being Moderated
Dear anyone,

I'm writing a game that loads Artificial Intelligence (AI) modules, which compete against each other.
I want to restrict the amount of memory available to these modules,
and thought perhaps I could use real-time Java for this
(hoping that a non-commercial JavaRTS-2 implementation will be released within some years).

I cannot ask the end users to install a real-time krenel and run the game with root privileges.
However, I don't need most real-time features of the real-time-JVM --- perhaps I only need these:

javax.realtime.MemoryParameters to restrict the amount of memory available to each AI thread, and the allocation rate.
javax.realtime.ReleaseParameters.setCost() to ensure that each AI module gets a fair amount of CPU time.
javax.realtime.PeriodicParameters to ensure that the game itself runs with a stable frame rate.

Now, this might be silly, I realize, but:

Would running Java-RTS-2 on a non-real-time OS (e.g. a vanilla Ubuntu kernel) be feasible with regard to what I want to achieve?

Would running Java-RTS-2 without root privileges be feasible with regard to what I want to achieve?

***

( When I start the Java-RTS-2 JVM without root privileges, it says:
Java Real-Time System HotSpot(TM) Client VM warning: unable to lock pages into memory
Java Real-Time System HotSpot(TM) Client VM warning: Cannot use the real-time scheduling class.
I guess that means that the scheduler fallbacks to default non-real-time JVM scheduling, and that ReleaseParameters & PeriodicParameters will have no meaning?
Any chance that javax.realtime.MemoryParameters still works fine? That would be enough for me (I hope I could trust the OS to slice the time fairly between the AI modules).
)

Kind regards,
Magnus
  • 1. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    In theory this is possible but in practice ... support for allocation rates in the heap is an optional facility in the RTSJ and Sun's Java RTS does not support it.

    Note also that the RTSJ memory semantics are not symmetrical:
    - you can control allocation rate in the heap, but not allocation amount
    - you can control allocation amount in immortal but not rate

    I think there may be something relating to scope too but don't have the details handy.

    Further, while you can get so far running Java RTS on a non-real-time system or without real-time privileges, MemoryParameters apply to real-time threads and real-time threads require certain capabilities be present in the OS or you can't create them at all.

    Sorry.

    David Holmes
  • 2. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    Okay. RTS-Java seems not to be the way to go for me then, as you said.

    ( I suppose I have to try something else, e.g. running each AI module in a different JVM,
    or instrumenting them to count how much memory they allocate and free. In case anyone
    is interested, I've started a thread about that here:
    [Restrict / monitor memory allocations -- per thread|http://forum.java.sun.com/thread.jspa?threadID=5277911&tstart=0] )

    ***

    I don't think I can use ScopedMemory, since garbage in a ScopedMemory area isn't recycled:
    objects allocated in scoped memory are freed when (and only when) no schedulable object has access to the objects in the scoped memory. .
    http://www.rtsj.org/specjavadoc/javax/realtime/ScopedMemory.html

    ***

    However, I think I found another RTSJ implementation that in some ways works in the way I want:

    The JamaicaVM
    [http://www.aicas.com/jamaica.html|http://www.aicas.com/jamaica.html]

    +[*Portability*|http://www.aicas.com/jamaica/doc/html/intro-port.html]+
    +...+
    Non-Realtime Operating Systems:+
    * Linux
    * SunOS/Solaris
    * Windows
    +Applications built with Jamaica on non-realtime operating systems may be interrupted non-deterministically by other threads of the operating systems. However, Jamaica applications are still deterministic and there are still no unexpected interrupts within Jamaica application themselves, unlike with other Java Virtual Machines.+

    Installation+
    +[Installation for a single user *without root privileges*|http://www.aicas.com/jamaica/doc/html/install.html#LINUXNONROOT]+
    +...bla bla bla...+

    But it's not free, it's only for JDK <= 1.4, and there are some limitations:

    +[...Jamaica for Windows contains the following limitations:|http://www.aicas.com/jamaica/doc/html/x3415.html#AEN3417]+
    +...+
    No graphics support is available. ...

    Anyway, I guess that within 10 years there'll be free Java-RTS-2.0++ implementations available (at least for non-commercial usage),
    some of them working on non-RT-OS, without any specific privileges :-)

    Thanks,
    Magnus
  • 3. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    Jamaica VM still might not provide heap allocation rate control - I don't know. But it is not a certified implementation of the RTSJ.

    ScopedMemory has its own issues but scopes do provide a way to get a very specific amount of memory available to a given thread. But if you need to share the objects in the scope then that is a problem. The simplest usage of scopes is as a thread-local scratchpad from which long-lived objects are copied out as needed (the objects need to support this) and the thread leaves and reenters the scope whenever it needs to get more memory space to use.

    David Holmes
  • 4. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    Yes, I don't think Jamaica VM had been an option, even if it had included graphics support on Windows.

    My intention with ScopedMemory was (when I thought that ScopedMemory was recycled whilst a thread was actively using it (but now I know it doesn't))
    to make private the constructors of [ all classes that needed to be shared between the AI-modules and the game itself ].
    Then, I would create [ static methods that invoked the private constructors ]
    and these static methods would in some way ensure that the shared objects were not placed in the ScopedMemory are but on the heap.

    The game (currently named MadMind (partly because it's hard to write reasonably good AI :-)))
    isn't to be released until after some years, or more likely, never, so I might as well wait for JDK 7, which I hope will include
    - JSR 284: Resource Consumption Management API, and
    - JSR 121: Application Isolation API Specification

    Then I can kill misbehaving AI modules too :-)

    Thanks again,
    Magnus
  • 5. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    hi,I am getting the same client vm warnings and I dont know how to remove them.I am a neophyte in this field and I request any one to help me out in this issue.I am working on linux(obuntu) and running this on VMWARE player.when I write a programme and run it on eclipse,it displays the above said client vm warnings.please help me .
  • 6. Re: Running Java-RTS on vanilla kernel, no root privileges
    807557 Newbie
    Currently Being Moderated
    hambi wrote:
    hi,I am getting the same client vm warnings and I dont know how to remove them.I am a neophyte in this field and I request any one to help me out in this issue.I am working on linux(obuntu) and running this on VMWARE player.when I write a programme and run it on eclipse,it displays the above said client vm warnings.please help me .
    The only way to "get rid of" the warnings is to execute with the necessary privileges. See the "Installation Guide", section "Granting Resource Access Privileges to Java RTS Users" for instructions on defining a "realtime" group with the needed privileges and then add yourself to that group. You will need root privileges to set this up.

    You can not run in a virtualized environment and expect real-time behaviour.

    David Holmes