Javolution rtsd

24
Javolution Real-Time System Design project, Stoenescu Serban

description

Javolution project for RTSD (university project)

Transcript of Javolution rtsd

Page 1: Javolution rtsd

Javolution

Real-Time System Design project,Stoenescu Serban

Page 2: Javolution rtsd

"The ability to simplify means to eliminate the unnecessary so that the necessary may speak."

Hans Hoffmann

Page 3: Javolution rtsd

What is Javolution?● Javolution is a Java API for real-time software

systems● Real-time systems imply:

● Higher execution speed● Time predictability

Page 4: Javolution rtsd

Advantages ● Some classes are easier to use than standard

classes in some SDKs or APIs.● Example: „You don't need to guess the capacity

of a TextBuilder, FastTable or a FastMap, their size expand gently without ever incurring expensive resize/copy or rehash operations (unlike StringBuilder, ArrayList or HashMap). „ [1]

Page 5: Javolution rtsd

Advantages (continued)● Javolution makes it easy for concurrent

algorithms to take advantage of multi-processors systems. [1]

● Example: Class ConcurrentContext● When a thread enters a concurrent context, it

may call the execute method, then continue with a concurrent thread immediately (or the thread itself if there is no concurrent thread immediately available)

Page 6: Javolution rtsd

Advantages (continued)● Real-time collection classes● Example: ArrayList (standard) vs. FastTable

(Javolution:● ArrayList may throw

ConcurrentModificationException● FastTable does not throw it (more thread-safe)

Page 7: Javolution rtsd

Advantages (continued)

● Provides Struct and Union classes for direct interoperability with C/C++;

Page 8: Javolution rtsd

Advantages (continued)● Most Javolution classes are stateless ([1])● state passed through parameters to methods or

available through Context classes● This design approach makes Javolution and

any product based on Javolution highly parrallelizable with no need for synchronization

Page 9: Javolution rtsd

Important Features● Context classes allow true separation of

concerns (eg. logging, performance, etc.)● Testing framework

● Allows assertions on execution time in nanoseconds

● World's fastest and first hard real-time XML marshalling/unmarshalling facility([1])

Page 10: Javolution rtsd

Example Classes

Page 11: Javolution rtsd

Context

● This class represents an execution context; they can be associated to particular threads or objects.

● Applications may extend this to facilitate separation of concerns

● Extended by: ● ConcurrentContext (see slide 5)● SecurityContext

Page 12: Javolution rtsd

SecurityContext● Used for separating security concerns.

Example for addressing security requirements ([1])public static boolean isReadAllowed(Table table) {

SecurityContext policy = SecurityContext.current();

return (policy instanceof DatabaseAccess.Permission) ?

((DatabaseAccess.Permission)policy).isReadable(table) : false;

}

Page 13: Javolution rtsd

High Performance IO Classes● CharSequenceReader● UTF8ByteBufferReader● UTF8ByteBufferWriter● UTF8StreamReader● UTF8StreamWriter

● Differences between this and standard StreamWriters:– Instances of this class can be reused for different output

streams.– Wrapping using a java.io.BufferedWriter is unnescessary

as instances of this class embed their own data buffers.

Page 14: Javolution rtsd

The Realtime Package● RealTimeInterface: defines RTSJ safe classes● RealtimeThread: time-predictable threads● Reflection.Constructor and Reflection.Method:

● Achieves some of the features provided by reflection

● Reflection is known to be slow

Page 15: Javolution rtsd

The javolution.util Package● Includes a lot of Javolution collection classes

that have counterparts in standard Java packages.● Examples:

– FastMap<K,V> - HashMap<K,V>– FastSet<E> - Set<E>– FastTable<E> - ArrayList<E>

Page 16: Javolution rtsd

The javolution.util Package (continued)

● StandardLog class: represents a specialized logging context forwarding events to a standard logger (java.util.logging.Logger) ([1])

● ReentrantLock: same functionality as standard locks

Page 17: Javolution rtsd

More features● javolution.xml and subpackages provide fast

XML processing features

Page 18: Javolution rtsd

Sample Application

Page 19: Javolution rtsd

Sample application● Application is similar reaction time tests in

driving schools● Used for testing and improving reaction times● User is shown some letters● He is supposed to press a key as fast as he can

if a vocal appears, before it disappears● Otherwise he is not supposed to press anything

Page 20: Javolution rtsd

Sample application (continued)● Uses RealtimeThread for controlling the output

and measuring reaction times● Also measures delays caused by threads● Uses FastSet to keep records of events

Page 21: Javolution rtsd

Reaction Time Measurement

Page 22: Javolution rtsd

Log and Statistics

Page 23: Javolution rtsd

Thread delays measurement (milliseconds)

Page 24: Javolution rtsd

References● [1] „Javolution” - http://javolution.org/