Javolution rtsd
-
Upload
serban-stoenescu -
Category
Education
-
view
414 -
download
6
description
Transcript of Javolution rtsd
Javolution
Real-Time System Design project,Stoenescu Serban
"The ability to simplify means to eliminate the unnecessary so that the necessary may speak."
Hans Hoffmann
What is Javolution?● Javolution is a Java API for real-time software
systems● Real-time systems imply:
● Higher execution speed● Time predictability
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]
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)
Advantages (continued)● Real-time collection classes● Example: ArrayList (standard) vs. FastTable
(Javolution:● ArrayList may throw
ConcurrentModificationException● FastTable does not throw it (more thread-safe)
Advantages (continued)
● Provides Struct and Union classes for direct interoperability with C/C++;
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
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])
Example Classes
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
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;
}
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.
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
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>
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
More features● javolution.xml and subpackages provide fast
XML processing features
Sample Application
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
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
Reaction Time Measurement
Log and Statistics
Thread delays measurement (milliseconds)
References● [1] „Javolution” - http://javolution.org/