se.lth.cs.realtime
Class RTSystem

java.lang.Object
  extended byse.lth.cs.realtime.RTSystem
All Implemented Interfaces:
RTSystemProperties

public class RTSystem
extends java.lang.Object
implements RTSystemProperties

See Also:
License

Field Summary
(package private) static int defaultEventBufferSize
           
(package private) static int lag
          Application time lag compared to system real time.
(package private) static int maxEventBufferSize
           
(package private) static int seq
          Tick counter for hidden thread below.
(package private) static int tickMillis
           
(package private) static int tickNanos
           
protected static int tol
          Permitted delay for ticker thread before lag increases.
 
Fields inherited from interface se.lth.cs.realtime.RTSystemProperties
DEPLOYED, NATIVE_SEM, OS_TICK_MICRO, PRIORITY_BASED, PRIORITY_STRICT, TIMEOUT_MS, TIMEOUT_NS
 
Constructor Summary
RTSystem()
           
 
Method Summary
static long currentTimeMillis()
          Obtain current 'real' time.
static int getDefaultEventBufferSize()
           
static int getMaxEventBufferSize()
           
static int getTickMillis()
           
static int getTickNanos()
           
static void sleep(long millis)
          Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds.
static void sleep(long millis, int nanos)
          Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds.
static void sleepUntil(long wakeUpTime)
          Causes the currently executing thread to sleep (temporarily cease execution) until the specified moment in time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultEventBufferSize

static int defaultEventBufferSize

lag

static transient volatile int lag
Application time lag compared to system real time.


maxEventBufferSize

static int maxEventBufferSize

seq

static transient volatile int seq
Tick counter for hidden thread below.


tickMillis

static int tickMillis

tickNanos

static int tickNanos

tol

protected static transient volatile int tol
Permitted delay for ticker thread before lag increases. Must be > tickMillis+1 below.

Constructor Detail

RTSystem

public RTSystem()
Method Detail

currentTimeMillis

public static long currentTimeMillis()
Obtain current 'real' time. If the JVM is not suspended (due to breakpoints and the like), if priorities are strictly considered for the scheduling, if deadlines are met, and if the time-base is based on unscaled real time, the returned time will be equal to System.currentTimeMillis(). For any two subsequent calls (from any threads), the second call is guaranteed to return a value greater than or equal to the value returned from the first call. That is, the time never decreases.

Returns:
Real time adjusted with respect to platform or debugging delays, permitting real-time programs to be tested from a concurrency point of view using a JVM or OS not providing real-time.

getDefaultEventBufferSize

public static int getDefaultEventBufferSize()
Returns:
default generic buffer size.

getMaxEventBufferSize

public static int getMaxEventBufferSize()
Returns:
upper limit of buffer sizes.

getTickMillis

public static int getTickMillis()
Returns:
clock tick period in number of milli-seconds.

getTickNanos

public static int getTickNanos()
Returns:
clock tick period in number of nano-seconds.

sleep

public static void sleep(long millis)
                  throws RTInterrupted,
                         RTDelayed
Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. The thread does not lose ownership of any monitors.

Parameters:
millis - the length of time to sleep in milliseconds.
Throws:
java.lang.IllegalArgumentException - if the value of millis is negative.
RTInterrupted - if another thread has interrupted this thread.
RTDelayed - if execution continues more than maxTimeLag too late.
See Also:
Thread.sleep(long)

sleep

public static void sleep(long millis,
                         int nanos)
                  throws RTInterrupted,
                         RTDelayed
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. The thread does not lose ownership of any monitors.

Parameters:
millis - the length of time to sleep in milliseconds.
nanos - 0-999999 additional nanoseconds to sleep.
Throws:
java.lang.IllegalArgumentException - if the value of millis is negative.
RTInterrupted - if another thread has interrupted this thread.
RTDelayed - if execution continues more than maxTimeLag too late.
See Also:
Thread.sleep(long, int)

sleepUntil

public static void sleepUntil(long wakeUpTime)
                       throws RTInterrupted,
                              RTDelayed
Causes the currently executing thread to sleep (temporarily cease execution) until the specified moment in time. Time is measured in milliseconds, starting from 00am, January 1st 1970, UTC. The thread does not lose ownership of any monitors.

Parameters:
wakeUpTime - the time to wake up.
Throws:
RTInterrupted - if another thread has interrupted this thread.
RTDelayed - if execution continues more than maxTimeLag too late.